下一页线有时破坏XML文件,并创建一个零长度的xml,OutOfMemoryException异常时抛出了。如何防止文件损坏?类型 'System.OutOfMemoryException的' 的阻止保存XML文件时,文件损坏
xmlDoc.Save(filename)
保存的异常被抛出。 (System.IO.FileStream.Write(Byte [] array,Int32 offset,Int32 count)在System.IO.StreamWriter.Flush(布尔flushStream,布尔 flushEncoder)在System.IO.StreamWriter.Write(Char值) System.Xml.XmlTextWriter.Indent(布尔beforeEndElement)在 System.Xml.XmlTextWriter.AutoComplete(令牌令牌)在 System.Xml.XmlTextWriter.WriteStartElement(字符串前缀,字符串 的localName,串NS)在 System.Xml.XmlDOMTextWriter.WriteStartElement(前缀字符串,字符串 的localName,串NS)在System.Xml.XmlElement.WriteTo(XmlWriter的W) 在System.Xml.XmlElement.WriteContentTo(XmlWriter的重量)在 System.Xml.XmlElement .WriteTo(XmlWriter w)在 System.Xml.XmlDocument.WriteContentTo(XW的XmlWriter)处 System.Xml.XmlDocument.Save(字符串文件名) System.Xml.XmlDocument.WriteTo(XmlWriter的w)的 MainOptions.Save(字符串文件名,ItemOptions选项)
这取决于许多因素,例如您的文档的大小试图保存或者是否有错误。根据您向我们展示的内容,我们无法告诉您。您需要向我们展示一些代码和您试图保存的XML。 – 2011-12-29 09:09:22
文件不是很大5Kb,并且由于项目选项更新而经常保存;单个选项更新错误不会导致文件损坏;在保存期间只有错误会这样做 – walter 2011-12-29 09:18:32
你想防止什么,覆盖以前的副本或错误本身? – Matten 2011-12-29 09:22:59