C# 如何在Azure function.Net项目中获取bin/debug/netcoreapp2.1路径?

C# 如何在Azure function.Net项目中获取bin/debug/netcoreapp2.1路径?,c#,.net,path,azure-functions,appsettings,C#,.net,Path,Azure Functions,Appsettings,当我构建项目时,我的appsettings.json文件和hosts.json文件将转到/bin/debug/netcoreapp2.1文件夹,但我的项目dll和所有其他库将转到/bin/debug/netcoreapp2.1/bin文件夹。现在,在我的azure函数中,我需要为我的.json文件动态创建的路径。我尝试的是: var appSettingsFileAbsPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssemb

当我构建项目时,我的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;
但它再次给出了/bin/debug/netcoreapp2.1/bin路径,其中存在dll。在我构建项目时,是否有任何函数可以从中获取json文件所在的/bin/debug/netcoreapp2.1路径

是否有任何函数可用于获取/bin/debug/netcoreapp2.1 我的json文件的路径

您的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 present

谢谢这就是我要找的。