C# reading and writing from & to same file
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/605685/how-to-both-read-write-file-in-c-sharp">How to both Read/Write File in C#</a>  </p>
</blockquote>



<p>I want to write and read text to and from the same text file. Here is the code </p>

<pre><code>TextWriter notesWriter = new StreamWriter("text.txt");
TextReader notesReader; = new StreamReader("text.txt"); 
</code></pre>

<p>Once the file is open for writing it is being locked and prevents to read from it.
So, some exception is thrown like,</p>

<blockquote>
  <p><em>The process cannot access the file 'text.txt' because it is being used by another process.</em></p>
</blockquote>

<p>what is the workaround for this ? thank you.</p>

<p>EDIT:
Suppose, if want to change text in a textbox and save it in a file and read from it when required to set the text in the textbox.</p>
