title: overwriting file with File.CreateText (C#)
body: <p>I am experiencing the following problem. I am using .NET Framework 1.1 and I am trying to overwrite a file using this code:</p>
  
  <pre><code>        try
          {
              using (StringWriter writer = new StringWriter())
              {
                  Server.Execute(path, writer);
  
                  using (StreamWriter sr = File.CreateText(filepath + fileName))
                  {
                      sr.WriteLine(writer.ToString());
                  }
              }
          }
          catch (Exception exc)
          {
              ...
          }
  </code></pre>
  
  <p>Sometimes it works fine, but sometimes it does not overwrite the file and no exception is thrown. Could someone tell me what the issue may be or how to handle why it doesn't overwrite the file?</p>