title: how to create .txt file and write it c# asp.net
body: <p>I am trying create and write to a text file in a C# application using the following code</p>
  
  <pre><code>System.IO.Directory.CreateDirectory(Server.MapPath("~\\count"));
  
  using (System.IO.FileStream fs = new System.IO.FileStream("~/count/count.txt", System.IO.FileMode.Create))
  using (System.IO.StreamWriter sw = new System.IO.StreamWriter("~/count/count.txt"))
  {
      sw.Write("101");
  }
  
  string _count = System.IO.File.ReadAllText("~/count/count.txt");
  Application["NoOfVisitors"] = _count;
  </code></pre>
  
  <p>but I get an error:</p>
  
  <blockquote>
    <p>The process cannot access the file 'path' because it is being used by another process.</p>
  </blockquote>
  
  <p>What is my error?</p>