title: C# Streamreader: Handling of special characters \" \' etc
body: <p>I'm reading then writing a text file.  Before and after the data of interest the file contains many lines that should remain unaltered.  But streamreader seems to convert the special characters ( <code>"</code> <code>'</code> <code>—</code> ) into other characters that appear as funky diamonds in both C# textboxes and in notepad.  How can text get passed through file read/write operations completely unaltered?  Thanks.</p>
  
  <pre><code>StreamWriter sw = new StreamWriter(sOutputFileName);
  using (StreamReader sr = new StreamReader(sTempFileName))
  {
     while (sr.Peek() &gt;= 0)
     {
         rdBuffer = sr.ReadLine();
         txtProgressDisplay.Text += rdBuffer + "\r\n";
  
         // parse and process some lines here
  
         wrBuffer = rdBuffer;
         sw.WriteLine(wrBuffer);
         txtProgressDisplay.Text += wrBuffer + "\r\n";
     }
     sr.Close();
  }
  sw.Close();
  </code></pre>