Results 1 to 5 of 5

Thread: [Resolved] Serializing List<FileInfo>

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Question [Resolved] Serializing List<FileInfo>

    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:

    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();
    Any ideas???
    Last edited by vbud; Oct 16th, 2006 at 05:20 AM. Reason: Resolved
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width