当我构建我的项目时,我的appsettings.json文件和hosts.json文件会转到/bin/debug/netcoreapp2.1文件夹,但是我的项目dll和所有其他库都会转到/bin/debug/netcoreapp2.1/bin文件夹。现在,在我的azure函数中,我希望为我的.json文件动态创建路径。我试过的是:
var appSettingsFileAbsPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + appSettingsFileName;但是,它再次给出了我的dll存在的/bin/debug/netcoreapp2.1/bin路径。当我构建项目时,有什么函数可以让我获得/bin/debug/netcoreapp2.1路径来获取json文件呢?
发布于 2020-02-02 02:48:30
是否有任何函数可以使我的json文件获得/bin/debug/netcoreapp2.1路径?
您的Json文件将位于dllGrandParentpath
var dllPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
var dllParentPath = Path.GetDirectoryName(dllPath);
var dllGrandParentPath = Path.GetDirectoryName(dllParentPath); // This is Where your appsettings.json file and hosts.json file is presenthttps://stackoverflow.com/questions/60020070
复制相似问题