0

Possible Duplicate:
Read file which is in use?

I am trying to access a file that is already in use in Windows 7. I have tried all the suggestions I could find on this site and other but no success yet.

What I have tried:

FileStream fs = new FileStream(iFile, FileMode.Open, FileAccess.Read, FileShare.Read);
FileStream fs = new FileStream(iFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
FileStream fs = new FileStream(iFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
FileStream fs = new FileStream(iFile, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);

Always the same error

The process cannot access the file 'fileinuse' because it is being used by another process.

I am open to any work arounds to this problem.

Thanks in advance for any help!

Community
  • 1
  • 1
lakedoo
  • 385
  • 1
  • 4
  • 13
  • @Josh, I tried the solution in that posting no luck :( – lakedoo Sep 16 '12 at 02:00
  • Maybe I should add that the file is being locked by W32MKDE.exe, not sure if that makes a difference. – lakedoo Sep 16 '12 at 02:01
  • 1
    if another process has opened a file in exclusive mode, there is usually a good reason for that. – Mitch Wheat Sep 16 '12 at 02:01
  • Windows Phone 7 may have different OS level mechanism around locking the file system. If that is the case you are probably SOL. At the end of the day it is up to the OS if you can access those bytes or not. – Josh Sep 16 '12 at 02:06
  • That "duplicate" question's answer covers the case *already tried* as per the post as is such a *poor "duplicate"* for this question. –  Sep 16 '12 at 02:10

1 Answers1

4

If another process opens the file in "exclusive mode" then you cannot get access to the file.

qehgt
  • 2,972
  • 1
  • 22
  • 36