Hi, I have a web service that logs some information to a text file; this web service is invoked asynchronously by a number of client apps, and this is causing a "The process cannot access the file because it is being used by another process" error.
This is the code I am using
FileStream fs = new FileStream(filename, FileMode.Append,
_FileAccess.Write, FileShare.Write);
writer = new StreamWriter(fs);
...
writer.Close();
No other code is accessing that file. Am I missing something?
Loading
MarcoPosted Jul 7, 2008, 4:24 AM
Ryan AlfordPosted Jul 5, 2008, 2:50 PM
MarcoPosted Jul 4, 2008, 9:38 AM
Is there any way to share a file for writing? I don't care about the order the data is written to the file, just that each write operation is atomic and does not stop the others.
Thanks
Sunny ChenPosted Jul 3, 2008, 8:47 PM
Did you have a try on the Mutex class?
I don't know if this helps in your scenario, you can have a check.
Hope this helps.