I am using a FileSystemWatcher to monitor a folder. But when there is some event happening in the directory, I don’t know how to search who made a impact on that file. I tried to use EventLog. It just couldn’t work. Is there another way to do it?
Share
I cant remember where I found this code but its an alternative to using pInvoke which I think is a bit overkill for this task. Use the
FileSystemWatcherto watch the folder and when an event fires you can work out which user made the file change using this code:Shell32 is a reference to the DLL: Microsoft Shell Controls And Automation – its a COM reference
Here is some example’s of how you call the method:
Or get multiple comma separated properties together:
Note: This solution has been tested on Windows 7 and Windows 10. It wont work unless running in a STA as per Exception when using Shell32 to get File extended properties and you will see the following error: