0

How to read XML files without writing full path, so my code would work when copied to other computers. With visual studio I added 2 XML files to project (Windows Application) and don't know best way to read those files.

  1. XElement element = XElement.Load("WH_Num.xml");

  2. XElement element = XElement.Load(@" C:\Users\nandang\Desktop\GUI_SETUP\JUNE_15_SetUp\3\Application Files\WH_Num.xml");

That Both 2 code are working for my PC, But when i publish and install setup file in other computer it wont work. please any one suggest me best way to give a XML path and that path could be work for all other computer.

Thank You.

vasim
  • 27
  • 5
  • You can try relative path, which means this path can be generated based on your program's executing path. Like your first one, it means the file is in the same directory with the program. Or, you can put the file in some public directory, like `Desktop`, `Document` or `userDir`, which you can get through `Environment.GetFloderPath()` method. For example, `Environment.GetFolderPath(Environment.SpecialFolder.Desktop);` will returns the path of `Deskop` directory. – ZelgiusLiu Jun 16 '20 at 08:02
  • Can please explain me how to use XML File name (WH_Num.xml) in that method ?? – vasim Jun 16 '20 at 09:22

0 Answers0