Can't find XML files in published C# project

  • Thread starter Thread starter cxarlos
  • Start date Start date
C

cxarlos

Guest
So I have created a Windows Forms app in C# using Visual Studio. The app saves data to .xml files in


C:\Users\Me\source\repos\MyApp\MyApp\bin\Debug

(default location), and works perfectly when building inside VS.

My program uses simple LINQ expressions to read from the .xml file:


XDocument.Load("myfile.xml");
// do something with it

However, when I try to publish the app and run as a standalone Application Manifest file, I get the following error when I try to read one of the .xml files:


Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'C:\Users\Me\AppData\Local\Apps.......

This is obviously cause by an incorrect file path, but how is it fixed? I have tried various methods online but nothing seems to be working. I can't move the .xml files from debug folder without breaking the build. I think I need to do something in the build properties?

Thanks!

Continue reading...
 
Back
Top