I want to keep a single XmlDocument object in a class and let methods make changes to it and save it.
using (FileStream fs = new FileStream(@"D:\Diary.xml",
FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(fs);
.... make some changes here
xmlDoc.Save(fs);
}
The above code makes two copies of the xml structure inside the file.