C# how to open a file that is locked by another process

added by gsanthoshbe
3/26/2010 4:45:51 AM


If the file is locked by the process exclusively, it is not possible to open those files. But if the process holds only shared lock, we can open the file using c# using the following code, FileStream objf = new FileStream(”Ouput.xls”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Excel hold the shared lock on the files. The Following is an example program to read a file,