title: Writing data from textbox into text file
body: <p>Here is the code im using to write and read from text file.</p>
  
  <pre><code>StreamWriter sw1 = new StreamWriter("DataNames.txt");
  sw1.WriteLine(textBox1.Text);
  sw1.Close();
  StreamWriter sw2 = new StreamWriter("DataNumbers.txt");
  sw2.WriteLine(textBox2.Text);
  sw2.Close();
  FileInfo file1 = new FileInfo("DataNames.txt");
  StreamReader sr1 = file1.OpenText();
  while (!sr1.EndOfStream)
  {
      listBox1.Items.Add(sr1.ReadLine());
  }
  FileInfo file2 = new FileInfo("DataNumbers.txt");
  StreamReader sr2 = file2.OpenText();
  while (!sr2.EndOfStream)
  {
      listBox2.Items.Add(sr2.ReadLine());
  }
  </code></pre>
  
  <p>The thing is that when I click my button to save data from my textboxes to my text files an error appears that says "The process cannot access the file 'C:\xxxx\xxxxxx\xxxxx\xxxx\xxxxx\xxxxx.txt' because it is being used by another process."</p>
  
  <p>Can anyone tell me why I have this error and maybe help me fix it</p>