using System.Xml;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(settingsFileName);
第一次(在启动时)它总是有效的,但是当文件更改时,我总是得到这个异常:
代码语言:
javascript
复制
Unhandled exception. System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)