I\'m playing around with C# and I encountered a problem. When I try to make a new file, the program breaks and says that the file is being used by another process. It\'s pro
File.Create returns a FileStream object which holds your file. You should use this object for further task.
var fileStream = File.Create(NameTb.Text + ".txt");
//... do all the writing using fileStream
fileStream.Close();
or you could do just
var fs = File.Create(NameTb.Text + ".txt");
fs.Close();
TextWriter tw = new StreamWriter(NameTb.Text + ".txt");
tw.WriteLine("The very first line!");
tw.Close();