BinaryReader got Exception error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I tried to open a binary file use BinaryReader.

BinaryReader binReader = new BinaryReader(File.Open(fileName, FileMode.Open,
FileAccess.Read, FileShare.Read));

This file is open by another process at the same time. An exception is
generated said "This file is being used by another process".

What should I do to open this file for read only and an exception error?
 
What else has the file open? It may have it open with FileShare.None. If you
don't have control over the application that's already got the file open,
then you may not be able to open it.

Pete
 
The file is open with CFile::shareDenyWrite flag from an C++ window applcation.
I can open this file for read by using MFC CFile, but not with C#
BinaryReader.

Angel
 
Back
Top