I created an application for Android in Xamarin.I open an xml file ,then I save the changes. I need to close it but xmldocument has not any option to do that. How can I close the file? I really need to do this because on other activity I want to modify it and it says :"Sharing violation on path"
If you're using the XmlDocument.Save just put a using around the TextWriter should do it:
var doc = new XmlDocument();
var filePath = "myXmlFile.xml";
doc.Load(filePath);
using (var writer = new StreamWriter(filePath))
{
doc.Save(writer);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.