当我调用此函数时,它只会打开几个空的记事本窗口,但如果我text2
在运行后打开文件,它会显示所有输入的行...我什至尝试刷新以写入缓冲区中的所有内容,但没有帮助。
static void finish()
{
FileStream fs2 = new FileStream("C:\\Users\\ayush.mishra\\Desktop\\text2.txt", FileMode.Create, FileAccess.Write);
using(StreamWriter s = new StreamWriter(fs2))
{
s.WriteLine("This Notepad will self destruct in....");
fs2.Flush();
Process notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
for (var i = 0; i < 40000000.00; i++);
notepadProcess2.CloseMainWindow();
s.WriteLine(" ****** 5 ****** ");
fs2.Flush();
notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
for (var i = 0; i < 400000000; i++);
notepadProcess2.CloseMainWindow();
s.WriteLine(" ****** 4 ****** ");
fs2.Flush();
notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
for (var i = 0; i < 400000000; i++);
notepadProcess2.CloseMainWindow();
s.WriteLine(" ****** 3 ****** ");
fs2.Flush();
notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
for (var i = 0; i < 400000000; i++);
notepadProcess2.CloseMainWindow();
notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
s.WriteLine(" ****** 2 ****** ");
fs2.Flush();
for (var i = 0; i < 400000000; i++);
notepadProcess2.CloseMainWindow();
notepadProcess2 = Process.Start("C:\\Users\\ayush.mishra\\Desktop\\text2.txt");
s.WriteLine(" ****** 1 ****** ");
fs2.Flush();
for (var i = 0; i < 400000000; i++);
notepadProcess2.CloseMainWindow();
}
}
有什么建议么?