Get username of open file

Is there any way to find out the name of the user who has the file open?

I am developing a program that will be a desktop client for many users. The application will open some files, and I would like many users to open files at the same time, but only allow the first user to have write permissions. I want you to be able to tell other users who have write access to the file.

Is this something that can be learned by the application? (I am developing in VS 2008).

+4
source share
1 answer

Windows does not support it. But you easily add it yourself. When you get write access to the file, write another hidden file with the username (Environment.UserName) in the same directory (for example, ~ originalname.username).

If you are unable to access the record, try opening this file to read the username. Sleep a second if this does not work.

+2
source

Source: https://habr.com/ru/post/1306271/


All Articles