How to get "Last saved by" of a file

How to get Last saved by of a file
Thank you in advance.

Hi @pondyondaime,

Please refer the below post,

@pondyondaime,

The below query will get you a single file which is last saved in a directory.

Directory.GetFiles("yourDirectoryPath").[Select](Function(f) New FileInfo(f)).OrderByDescending(Function(fi) fi.LastWriteTime).First().ToString

I want to know name of account who save file not modify time, seem to get who modify it using not using System.IO.FileInfo.

@pondyondaime,

Okay, then try with the below query, it will give you the username of the last modified file in a directory

Directory.GetFiles("yourDirectoryPath").[Select](Function(f) New FileInfo(f)).OrderByDescending(Function(fi) fi.LastWriteTime).First.GetAccessControl().GetOwner(GetType(System.Security.Principal.NTAccount)).ToString()
2 Likes

After i try it output was my Computer name
image

I want file information below picture

Do you have any suggestion?

@pondyondaime Your are not only getting Computer name, you are also getting UserID of the User.
0ef04dc335014ee065406709464dc37a6dbf7b1d

Please find the working sample file LastSavedBy.xaml (5.4 KB)

It requires Spire.XLS Package. This workflow works for Excel Files only, if you want to work with other Docs, then switch to the other Spire Package.

Cheers @pondyondaime :slightly_smiling_face:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.