Erika
Erika

Reputation: 21

Find file creator in vb?

Is there any way to get the creator of a file using vb8? Can't seem to find anything that will work. I need to find the creator of each file in a directory of hundreds of files.

Upvotes: 2

Views: 3520

Answers (2)

smkndblvr
smkndblvr

Reputation: 91

A bit late, but should help anyone else looking for this info.

Using the WindowsAPICodePack Shell packages the file creator/ last modified by information can be easily obtained.

Dim sf As Microsoft.WindowsAPICodePack.Shell.ShellFile

Dim authors As String = sf.Properties.GetProperty("System.Author").FormatForDisplay(PropertySystem.PropertyDescriptionFormatOptions.None)

Dim lastModifiedBy As String = sf.Properties.GetProperty("System.Document.LastAuthor").FormatForDisplay(PropertySystem.PropertyDescriptionFormatOptions.None)

More info on Windows Property System can be found here.

Upvotes: 0

Bala R
Bala R

Reputation: 109027

You can try something like this to get the file owner

Dim fs As FileSecurity = File.GetAccessControl("someFileName.ext")
Dim sid As IdentityReference = fs.GetOwner(GetType(SecurityIdentifier))
Dim ntaccount As IdentityReference = sid.Translate(GetType(NTAccount))
Dim owner As String = ntaccount.ToString()

Upvotes: 3

Related Questions