title: Write to a binary file with C#
body: <p>I'm trying to encrypt a string and write it to a binary file. I want to do the process in reverse. Here is the code I have but it doesn't work.</p>
  
  <pre><code>FileStream stream = new FileStream(saveFileDialog1.OpenFile().ToString(),   FileMode.Create);
  BinaryWriter writer = new BinaryWriter(stream);
  String temp = "";
  serialList.ForEach(delegate(record p)
  { 
      temp = String.Format("{0},{1}#", p.serial, p.option);
      byte[] dataB = System.Text.Encoding.Unicode.GetBytes(String.Format("{0},{1}#", p.serial, p.option));
      byte[] enc = Encrypt(dataB, "gio!");
      writer.Write(enc);
  });
  writer.Write('1');
  writer.Close();
  stream.Close();
  </code></pre>
  
  <p>What is wrong with it??</p>