Hello all, i'm facing problems to serialize a generic list of FileInfo classes. My problem is that I need to retrieve the list of files in a directory and then save that list. The idea is to serialize that list and deserialize it when needed. i'm not sure if its a right thing to serialize a whole fileinfo class or would it be easier for have a custom class holding only the filenames, any suggestion in that sense would be most welcomed. Anyways here's my piece of code:
Any ideas???Code:// declared in a form private List<FileInfo> Files = new List<FileInfo>(); // in some method // following line giving me error saying cannot serialize since FileInfo does not have a parameterless constructor... ??? XmlSerializer xSr = new XmlSerializer(typeof(List<FileInfo>)); Stream stm = new FileStream("c:\\Test", FileMode.CreateNew); xSr.Serialize(stm, Files); stm.Close();




Reply With Quote