I believe that the process in which the file is open is your own process.
When you call saveDialog1.OpenFile (), you open the file and the stream is returned.
Then you call WriteAllText (), which tries to open the same file again, leading to the exception above.
You could just delete the OpenFile () call
If saveFileDialog1.ShowDialog() = DialogResult.OK Then File.WriteAllText(saveFileDialog1.FileName, TextBox1_Output_Module.Text & vbCrLf & TextBox2_Output_Module.Text & vbCrLf & TextBox3_Output_Module.Text) End If
Just keep in mind that WriteAllText () creates a new file, writes the specified line to the file, and closes the file. If the target file already exists , it is overwritten.
Steve source share