I'm doing the following:
var streamWriter = new FileStream("foo.bin", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
Thus, I want to open foo.bin (or create it if it does't exist); I want to read and write to it from streamWriter, and I want others to be able to open it for reading. But when I subsequently do this:
var streamReader = File.OpenRead("foo.bin");
I get the exception The process cannot access the file 'foo.bin' because it is being used by another process.
What gives? I did want others to be able to open it for reading...