David Smith

David Smith

  • NA
  • 2k
  • 0

Empty XML Docuement File error

Jul 25 2013 11:56 AM
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)