title: Serialization and Deserialization into an XML file, C#
body: <p>I have the following code:  </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  
  namespace ConsoleApplication28
  {
  class Program
  {
  
      static void Main()
      {
          List&lt;string&gt; dirs = FileHelper.GetFilesRecursive(@"c:\Documents and Settings\bob.smith\Desktop\Test");
          foreach (string p in dirs)
          {
              Console.WriteLine(p);
          }
  
          //Write Count
          Console.WriteLine("Count: {0}", dirs.Count);
          Console.Read();
  
      }
  
      static class FileHelper
      {
          public static List&lt;string&gt; GetFilesRecursive(string b)
          {
              // 1.
              // Store results in the file results list.
              List&lt;string&gt; result = new List&lt;string&gt;();
  
              // 2.
              // Store a stack of our directories.
              Stack&lt;string&gt; stack = new Stack&lt;string&gt;();
  
              // 3.
              // Add initial directory.
              stack.Push(b);
  
              // 4.
              // Continue while there are directories to process
              while (stack.Count &gt; 0)
              {
                  // A.
                  // Get top directory
                  string dir = stack.Pop();
  
                  try
                  {
                      // B
                      // Add all files at this directory to the result List.
                      result.AddRange(Directory.GetFiles(dir, "*.*"));
  
                      // C
                      // Add all directories at this directory.
                      foreach (string dn in Directory.GetDirectories(dir))
                      {
                          stack.Push(dn);
                      }
                  }
                  catch
                  {
                      // D
                      // Could not open the directory
                  }
              }
              return result;
          }
      }
  }
  }
  </code></pre>
  
  <p>The code above works well for recursively finding what files/directories lie in a folder on my c:.<br>
  I am trying to serialize the results of what this code does to an XML file but I am not sure how to do this.  </p>
  
  <p>My project is this:  find all files/ directories w/in a drive, serialize into an XML file.  Then, the second time i run this app, i will have two XML files to compare.  I then want to deserialize the XML file from the first time i ran this app and compare differences to the current XML file and produce a report of changes (i.e. files that have been added, deleted, updated).  </p>
  
  <p>I was hoping to get some help as I am a beginner in C# and i am very very shaky on serializing and deserializing.  I'm having lots of trouble coding.  Can someone help me?</p>
  
  <p>Thanks</p>