13
Reply

Empty XML Docuement File error

David Smith

David Smith

Jul 25 2013 11:56 AM
1.2k
I get an error below when an xml file is blank or empty. What to do in this case???? 

Error Received: There is an error in XML Document (0,0)

  XmlSerializer serializer = new XmlSerializer(typeof(Colors));
  TextReader textReader = new StreamReader(colorName);
  colorfile = (Colors)serializer.Deserialize(textReader); Error on this line of code, What to do for this case when the file is empty??? I want to to be able to still save data to the file.
  textReader .Close();

  When deserializing the object is the file is empty and I get a document error. I am assuming the because do not the xml document header attributes,


Answers (13)