开发者

Find file creator in vb?

Is there any way to g开发者_Python百科et 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.


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()


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜