views:

396

answers:

3

Hi everyone.

Is there ability to read file that is used by another process?

Thanks.

+7  A: 

If the process holds an exclusive lock on the file then no. If the process holds a shared lock, you can read it.

Mehrdad Afshari
if a process holds a hared lock, it's possibleto read file like this:using (var stream = new FileStream(@"d:\myfile.xls", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)){...}
iburlakov
A: 

It depends on how the other process opened the file (i.e., is it locked). Bear in mind that reading a file while it is being changed by another process may yield unexpected results.

Traveling Tech Guy
+1  A: 

Depending on the files you want to access, have a look at Volume Shadow Copy.

Maltrap