1
我正在嘗試使用控制檯在文件中編寫代碼。我成功完成了它。但問題是,關閉我的文件之間的連接後,我無法在控制檯中寫入。我正確與文件斷開連接。我的代碼中有沒有問題?在寫入文件後無法在控制檯中寫入
var outfilename = Path.Combine(Environment.CurrentDirectory, "name.txt");
var outname = new StreamWriter(outfilename);
Console.SetOut(outname);
Console.WriteLine("aiiii");
outname.Close();
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()));
Console.Write("hai");
string nam1=Console.ReadLine();
Console.WriteLine(nam1);
Console.ReadLine();