I need to read a file that is opened for writing in other part of the program
const string fileName = "file.bin";
FileStream create = File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.Read);
FileStream openRead = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
The last line raises IOException:
"The process cannot access the file because it is being used by another process"
Please help properly configure File.Open parameters.
Change
FileShareparameter toFileShare.ReadWritein both statement:ReadWriteflag description from MSDN: