title: Read and write to a file in the same stream
body: <p>I'm trying to read and write to the same file in a way such that no other program can access the file in between:</p>
  
  <pre><code>  FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);               
    StreamReader sr = new StreamReader(fs);
    StreamWriter sw = new StreamWriter(fs);
    newString = sr.ReadToEnd() + "somethingNew";
    sw.Write(newString);
    fs.Close();
  </code></pre>
  
  <p>The file is never written to. If I debug I can see that the reader manages to fetch the contents of the file, but the writer does not seem to be able to write to the file. Nothing happens.</p>
  
  <p>I've been looking at <a href="https://stackoverflow.com/questions/605685/how-to-both-read-and-write-a-file-in-c-sharp">this question</a> which seems to be the same as mine. However I'm not able to get it to work.</p>