Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的原始 xml 文件不完整,它抛出异常: Unexpected end of file has occurred 。以下元素未关闭 rrrr, nnnn
XML 文件,例如:
<rrrr> <nnnn> <aaaa> </aaaa> <bbbb> </bbbb>
如何使用 C# 编辑此文件以包含 </nnnn></rrrr>?
</nnnn></rrrr>
最简单的使用File.AppendText方法:
File.AppendText
using (StreamWriter w = File.AppendText(filePath)) { w.WriteLine("</nnnn>"); w.WriteLinw("</rrrr>"); }