title: I am having trouble pasting a serialized string into .txt and un-serializing it to retrieve the original value
body: <p>I am having some trouble figuring out how to do this since I have never serialized before. I am able to turn strings into byte[]s and then serialize them to a new string but am unable to save that serialized string to a text file, re-import it and convert it back to get the original value. Keep in mind this is a learning project. This is what I am doing so far</p>
  
  <pre><code>private string SerializeToString(string obj)
      {
          if (obj == null)
              return null;
  
          System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
          MemoryStream ms = new MemoryStream();
          bf.Serialize(ms, obj);
          byte[] Array = ms.ToArray();
  //This is where I create the txt file and write to it
              File.OpenWrite(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)     + "\\Text.txt")
              .Write(Array, 0, Array.Length);
  
  
  
          ms.Close();
          return Convert.ToBase64String(Array);
      }
  
          private void txtCheck_Click(object sender, RoutedEventArgs e)
      {
  //I uploaded the file to drop box and can successfully download it but can not figure out
  //how to get the original value out of it..
          string Url = "http://dl.dropbox.com/u/62170850/Text.txt";
          WebClient webClient = new WebClient();
          //webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
          //webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
          byte[] myDataBuffer = webClient.DownloadData(new Uri(Url));
          string s = Convert.ToBase64String(myDataBuffer);
      }
  </code></pre>