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

Sunny Chen162 reputationPosted Jul 3, 2008, 4:47 PM EDT
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.
Marco5 reputationPosted Jul 4, 2008, 5:38 AM EDT
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
Ryan AlfordRank #1,411 · 1.2K reputationPosted Jul 5, 2008, 10:50 AM EDT
Marco5 reputationPosted Jul 7, 2008, 12:24 AM EDT