2

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.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Erika
  • 21
  • 2
  • 3

2 Answers2

3

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()
Bala R
  • 107,317
  • 23
  • 199
  • 210
  • That worked great... But I just discovered that somehow all the files have the same author. Checked file properties and found out that the name I need is actually "last saved by". Is it possible to get that? – Erika Jul 21 '11 at 14:27
  • @Erika I know of a "last modified date" field but nothing about a "last saved by". Can you elaborate and/or provide reference to what it is? – Bala R Jul 21 '11 at 14:35
  • Once the files are in this folder, they are static. I need to see the last person to write & save the document aka LAST author. Does that make sense? – Erika Jul 21 '11 at 14:40
  • Does Windows even maintain that data? – Chris Dunaway Jul 27 '11 at 16:03
0

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.

Community
  • 1
  • 1
smkndblvr
  • 91
  • 6