Is this what you are looking for?
FileStream currentFileStream = null;//EDIT
string tempFilePath = Directory.GetCurrentDirectory() + "\\TEMP.txt";
if (!File.Exists(tempFilePath))
{
currentFileStream = File.Create(tempFilePath);//creates temp text file
currentFileStream.Close();//frees the file for editing/reading
}//if file does not already exist
File.WriteAllText(tempFilePath, textbox1.Text);//overwrites all text in temp file
//Inside your exit function:
if(File.Exists(tempFilePath)) File.Delete(tempFilePath);//delete temp file
2
solved Write text file and open at same time