user726720
user726720

Reputation: 1247

Original XML file not complete throwing exception

My original xml file is not complete it's throwing an exception: Unexpected end of file has occured . the following elements are not closed rrrr, nnnn

XML file e.g.:

<rrrr>
<nnnn>
<aaaa>
</aaaa>
<bbbb>
</bbbb>

How can I edit this file using C# to include </nnnn></rrrr> ?

Upvotes: 0

Views: 70

Answers (1)

MarcinJuraszek
MarcinJuraszek

Reputation: 125660

The simplest one would use File.AppendText method:

using (StreamWriter w = File.AppendText(filePath))
{
    w.WriteLine("</nnnn>");
    w.WriteLinw("</rrrr>");
}

Upvotes: 3

Related Questions