Posted By

jalalx on 01/18/11


Tagged

xml serialize deserialize


Versions (?)

CanXmlDeserialize


 / Published in: C#
 

Checks for can XML Deserialize file.

  1. public static bool CanXmlDeserialize<T>(string filename)
  2. {
  3. bool result = false;
  4. try
  5. {
  6. XmlReader reader = XmlReader.Create(filename);
  7. XmlSerializer serializer = new XmlSerializer(typeof(T));
  8. result = serializer.CanDeserialize(reader);
  9. reader.Close();
  10. }
  11. catch
  12. {
  13. result = false;
  14. }
  15. return result;
  16. }

Report this snippet  

You need to login to post a comment.