I'm trying to use the XmlTextWriter class in C# but it only works if I give the complete path to the file (as in "C:\file.xml"). If I try to use relative path (as in "file.xml"), it creates the file (in the same folder that contais the cs file) but it doesn't show any contents. Is there any property in the project tree in VS I have to set so that the file is updated everytime I run the program?
Some code to help:
If I do:
XmlTextWriter f = new XmlTextWriter("C:/file.xml", null);
it works.
But if I try to use a file that is included in the project ,like this:
XmlTextWriter f = new XmlTextWriter("file.xml", null);
it doesn't work. The file remains empty.
Thnaks in advance.
It is your responsibility to provide the XMLWriter with a valid file name including the path. This file path can be relative or absolute. The thing is that relative path will work against whatever the current directory will be in at the RUNTIME not what you would expect it to be looking at the source in the designer.
In particular if you give just the filename - no path, the file with the specified name will probably be created right next to your .exe file