好吧,所以我不知道为什么我不能写入文件。它说它正在被另一个进程使用。这是错误(IOException 未处理):
The process cannot access the file 'C:\Temp\TempFile.cfg' because it is being used by another process.
这是我用来写入文件的当前代码:
Dim myConfig
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "Configuration Files (*.cfg)|*.cfg"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myConfig = saveFileDialog1.OpenFile()
If (myConfig IsNot Nothing) Then
System.IO.File.WriteAllText(saveFileDialog1.FileName, TextBox1_Output_Module.Text & vbCrLf & TextBox2_Output_Module.Text & vbCrLf & TextBox3_Output_Module.Text)
myConfig.Close()
End If
End If
我不确定我错过了什么,因为我以为我昨天测试过它并且它有效。