Try this
Include namespace "System.IO"
string path = @"D:\YourPath\Test.txt";
if (!File.Exists(path))
{
File.Create(path);
TextWriter tw = new StreamWriter(path);
tw.WriteLine("test line 1!");
tw.Close();
}
else if (File.Exists(path))
{
TextWriter tw = new StreamWriter(path, true);
tw.WriteLine("test line 2!");
tw.Close();
}
string texts = ReadAllText(@"D:\YourPath\Test.txt");
System.Console.WriteLine("File Test.txt contains = {0}", texts);
In case, this doesn't solve your problem, please reply.