1

I have to reference FolderX in my application after publish/deploy in Azure... The folder FolderX is in my publish Folder, but everytime I try access get me a error: "Directory not found: \n/home/site/FolderX !"

I have the following code in my csproj:

<ItemGroup>
  <Content Include="FolderX\**" CopyToPublishDirectory="PreserveNewest"/>
</ItemGroup>

Now, I have to reference FolderX in my application after publish/deploy in Azure... The folder FolderX is in my publish Folder, but everytime I try access get me a error: "Directory not found: \n/home/site/FolderX !"

Since in my publish Folder, "FolderX" is in the same level of wwwrot, I try reference FolderX in this way:

string filePath = Assembly.GetExecutingAssembly().Location + @"\"; //pick a path "wwwrot" and return 1 folder
string filePath2 = Path.GetDirectoryName(filePath);
string DiretorioSchemas = Path.GetDirectoryName(filePath2) + "/FolderX";

But It's continues give me a error: "FolderX not found!". Where am i going wrong?


EDIT: Thanks @rahularyansharma

Resolve: Get XML comments output file location for ASP Core

Note: dotnet 6.0 removed this lib, so for this implementation a nugget must be downloaded.

string basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath;
string folderPath = Path.Combine(basePath, "FolderX");
Cristopher
  • 11
  • 2
  • Is your application hosted in Azure App Service ? – rahularyansharma May 02 '23 at 12:19
  • Hi, yes... It was hosted in Azure App Service – Cristopher May 02 '23 at 12:42
  • https://stackoverflow.com/questions/36691004/get-xml-comments-output-file-location-for-asp-core – rahularyansharma May 02 '23 at 13:29
  • 1
    Thanks! This worked for me... Note: dotnet 6.0 removed this lib, so for this implementation a nugget must be downloaded. For me: ```string basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; string folderPath = Path.Combine(basePath, "FolderX");``` – Cristopher May 02 '23 at 16:55

0 Answers0