Answer the question
In order to leave comments, you need to log in
XmlSerializer in c# duplicates last 2-3 characters when writing to file?
Hello everybody.
I use the following code in c# to serialize an object to xml and write it to a file:
XmlSerializer formatter = new XmlSerializer(typeof(Config));
using (FileStream fs = new FileStream(File, FileMode.OpenOrCreate))
{
formatter.Serialize(fs, Current);
}
<?xml version="1.0"?>
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ActivityTime>
<FromTimeString>PT9H</FromTimeString>
<ToTimeString>PT23H</ToTimeString>
</ActivityTime>
<ThreadsCount>2</ThreadsCount>
</Config>ig>>
Answer the question
In order to leave comments, you need to log in
solved the problem, instead of FileMode.OpenOrCreate you need to use FileMode.Create
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question