I am trying to get last modified by user name but I am not able to get the user name. I searched lot on Google but I am confuse now. Because In some thread I found that last modified user is not able to get. And Other link gives some code. I used that code but last modified user is not getting retrieved.
Is there any one who get the last modified user name using c# code?
Is it possible?
This should give you the last modified file and the user who changed it:
var dir = new DirectoryInfo(path);
var lastModified = dir.GetFiles()
.OrderByDescending(fi => fi.LastWriteTime)
.First();
string modifiedBy = lastModified.GetAccessControl()
.GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
"Powered by": Finding the user who modified the shared drive folder files
Edit: actually this gives you only the owner of the file that was last modified.
It seems that windows simply doesn't keep track of this. You could use a FilesystemWatcher to do it yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With