BinaryReader got Exception error

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?
 
P

Pete Davis

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top