The File.Create
method creates the file and opens a FileStream
on the file. So your file is already open. You don't really need the file.Create method at all:
string filePath = @"c:\somefilename.txt";
using (StreamWriter sw = new StreamWriter(filePath, true))
{
//write to the file
}
The boolean in the StreamWriter
constructor will cause the contents to be appended if the file exists.