0

My project has a resource folder that contains pictures and xml files. The program can access the files just in debug mode. When I installed the solution, and run the program it doesn't work. How can I publish my Win Forms solution that it could access the resource folder after install? Here is my VB code that can pretty good access the files in runtime: myPath = "myResources\" & fileName & ".xml"

LewoSoft
  • 73
  • 1
  • 2
  • 12
  • It sounds like you want [Copying Visual Studio project file(s) to output directory during build](https://stackoverflow.com/a/10828462/1115360). – Andrew Morton Feb 03 '20 at 10:17
  • Don't use the Resources folder as repository. Visual Studio uses that folder as storage for files that are embedded as Resources. Create you own folder(s) structure. You can add folders in Solution Explorer and set `Copy to Output Directory = Copy if newer` to all files you want to copy to the build Directories (Debug, Release etc). The you can use, for example, `dim myXmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyXmlFolder")`, where `MyXmlFolder` is a folder you created in Solution Explorer. It can contain sub-folders, of course. – Jimi Feb 03 '20 at 11:07
  • Thank you guys! @Jimi Yes, it wasn't "ordinary" resource folder before, just a simply added folder in my solution. – LewoSoft Feb 03 '20 at 12:30

1 Answers1

0

The correct path is this: myXmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyXmlFolder", myFileName & ".xml") The correct properties for the files: -Build action: Content -Copy to Output Directory: Copy if newer

LewoSoft
  • 73
  • 1
  • 2
  • 12
  • I notice that you have given an answer, have you solved the current problem? If so, it is recommended that you mark it as the answer, as it will be beneficial to others. – Julie Xu-MSFT Feb 04 '20 at 03:48