4
Answers

Concurrent file write-access

Marco

Marco

16y
15.8k
1
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?

Answers (4)