G
Guest
Hi
Im trying to make an app that uses threading, I want to write to a file in a
loop.
How can i ensure that only one thread writes to the file a the time???
Im accessing the fil with:
Dim xFile As StreamWriter
xFile = New StreamWriter("C:\threadtest.txt", True, System.Text.Encoding.UTF8)
xFile.Write(Now)
xFile.Flush()
xFile.Close()
The error:
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"C:\threadtest.txt" because it is being used by another process.
Im trying to make an app that uses threading, I want to write to a file in a
loop.
How can i ensure that only one thread writes to the file a the time???
Im accessing the fil with:
Dim xFile As StreamWriter
xFile = New StreamWriter("C:\threadtest.txt", True, System.Text.Encoding.UTF8)
xFile.Write(Now)
xFile.Flush()
xFile.Close()
The error:
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"C:\threadtest.txt" because it is being used by another process.