该
File.Create方法创建文件并在文件上打开一个
FileStream。因此,您的文件已经打开。您根本不需要file.Create方法:
string filePath = @"c:somefilename.txt";using (StreamWriter sw = new StreamWriter(filePath, true)){ //write to the file}StreamWriter如果文件存在,则构造函数中的布尔值将导致附加内容。

该
File.Create方法创建文件并在文件上打开一个
FileStream。因此,您的文件已经打开。您根本不需要file.Create方法:
string filePath = @"c:somefilename.txt";using (StreamWriter sw = new StreamWriter(filePath, true)){ //write to the file}StreamWriter如果文件存在,则构造函数中的布尔值将导致附加内容。