title: how replace all spaces in a text file with one character?
body: <p>i have a text file like below :   </p>
  
  <pre><code>string string
  string                 string
  string   string
  string          string
  </code></pre>
  
  <p>i want to replace all these spaces with pipe (|) character.<br>
  is there any method in c# for doing that?  </p>
  
  <p>i am using the below codes for read and write on file :<br>
  <a href="https://stackoverflow.com/questions/1368539/how-do-i-read-and-edit-a-txt-file-in-c">How do I read and edit a .txt file in C#?</a></p>
  
  <p><strong>EDIT:</strong><br>
  after using the codes in the accepted answer i got the  below error in line of<br>
  <strong>System.IO.File.WriteAllLines( ...</strong>:</p>
  
  <blockquote>
    <p>Could not find file 'C:\Program Files\Common Files\Microsoft
    Shared\DevServer\10.0\infilename.txt'.</p>
  </blockquote>
  
  <p>[Solves by absolute path]  </p>
  
  <p><strong>thanks for comments and answers :</strong><br>
  not each space with one pipe -> all spaces in each line with one pipe... </p>
  
  <p>thanks in advance</p>