I need to open and XML file. The requirement is to be able to open it as read-only, and as read-write as well.
I tried the code below, but so far I can still write to the file.
var myFileStream = new FileStream(@"XMLFile.xml",FileMode.Open, FileAccess.Read, FileShare.Read);
var Reader = XmlReader.Create(myFileStream);
var XDoc = XDocument.Load(Reader, LoadOptions.PreserveWhitespace);
myFileStream.Close();