I am not aware of any function to do so, indeed when you try to delete a file in windows that is used by another process it also states that another process is using the file but it does not say to you which one.

I'd like to know the answer to this too (open a file for read that is already open by an external process).

As a workaround I copied the file (File.Copy(.....) ) and opened the copy. Its really annoying since my text editor can open a file that is currently locked by another process, the copy process *may* be reading the bytes when copying, but C# won't let me open for read access the very same file.

Well, to open the file that is already open by other process I had to specify FileShare.ReadWrite. That is with FileShare you specify what other users can do with that file, not what you will do with it.

According to MSDN,"A typical use of this enumeration is to define whether two processes can simultaneously read from the same file. For example, if a file is opened and Read is specified, other users can open the file for reading but not for writing."

Have a question. l want to disable system file protection on my xp sp2, so l downloaded the the sfc_os.dll (2600.1106) and created a backup sfc_os.bak opened it with hexeditor and changed the values, everything like is mentioned here in this link http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=510 but when l had to import the one in the system32 folder using cmd.exe a message appears containing the following "The process cannot access the file because it is being used by another process. 0 files copied. the command l am attempting to put is "copy sfc_os.bak sfc_os.dll /y" but it does not work for me. Anyway it worked well in the dllcache folder. Please anyone who can help? l need to disable WFP because l need to replace some essential files for my new graphic editor. Thanks help much appreciated !!

Then before using the file close the file as a standard practice. If system not allows the file to close then open it in sharing mode i think it will help you. to close a file use file.close() method. and to open in share mode user

try this , simple and its is like fake sign to threads, while file is using by particular threads check for its availability. this idea will works for hundreds of request to a sing file and it will log each and every stream to file :).