I am trying to create an XML file for storing some info from a class. I gave the path as a const set to Info.xml
. but the XMLTextWriter
is not saving the XML file to bin(debug/release) folder, rather it is saving it to MyDocuments folder. When i tried to check if the file exists with File.Exists(path)
, its returning false. Could somebody please guide me here.
My code looks as below...
string BookName = "Book1"
string AuthorName= "Author1"
XmlTextWriter writer = new XmlTextWriter("Info.xml", Encoding.UTF8); writer.WriteStartDocument();
writer.WriteStartElement("Title");
writer.WriteString(BookName);
writer.WriteStartElement("Author");
writer.WriteString(AuthorName);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();