I would like to add a convenient file lock to Windows software (mainly Windows 7) written in C # . I have already reached the file lock part by keeping the used files βopenβ in the corresponding process. What I would now like to add is the recognition of a user who has a file that is open or locked by a file.
Access to files lies on a mapped network drive , which is used by different users on different computers. When the file is locked, and the second one tries to open the file, it should encounter a dialog similar to the File in Use dialog box from Microsoft Office programs. It also displays the name of the user who is currently editing the file.
I found solutions to find out processes that have a specific open file (this one is used: How do I know which process blocks a file using .NET? ) And I can also read the name of the user who created this process. However, when opening a locked file on a network drive, the user name obtained in this way is always my own, and not one of the users who block the file.
Does anyone have any ideas how to achieve this? I mean, Microsoft Office can do this on my PC with the same permissions. I just wanted to know how ...
Hurrah!
source
share