I need to get some info from a file, like in windows search.
I already found DateModified DateCreated Path.
But now I want the file type(like in windows search) and owner.
This is my code to get the info I already have:
Dim strLastModified As String
Dim strCreate As String
Dim strOwner As String
Dim strType As String
Dim strName As String
strLastModified = System.IO.File.GetLastWriteTime(path)
Dim fs = File.GetAccessControl(path)
strCreate = System.IO.File.GetCreationTime(path)
strOwner = fs.GetOwner(TypeOf(securityIdentifier)) 'Error on this part'
strType = System.IO.File.TypeName(path) 'Error on this part'
lordplazikov...
Member
195 Points
319 Posts
File Info
May 02, 2012 10:08 AM|LINK
Hi guys,
I need to get some info from a file, like in windows search.
I already found DateModified DateCreated Path.
But now I want the file type(like in windows search) and owner.
This is my code to get the info I already have:
Dim strLastModified As String
Dim strCreate As String
Dim strOwner As String
Dim strType As String
Dim strName As String
strLastModified = System.IO.File.GetLastWriteTime(path)
Dim fs = File.GetAccessControl(path)
strCreate = System.IO.File.GetCreationTime(path)
strOwner = fs.GetOwner(TypeOf(securityIdentifier)) 'Error on this part'
strType = System.IO.File.TypeName(path) 'Error on this part'
Thanks in advance.
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: File Info
May 02, 2012 10:18 AM|LINK
strOwner = fs.GetOwner(TypeOf(Security.Principal.NTAccount))
Space Coast .Net User Group
lordplazikov...
Member
195 Points
319 Posts
Re: File Info
May 02, 2012 10:48 AM|LINK
'Security' is ambiguous, imported from the namespaces or types 'system.web', System
This are my imports:
Imports System.IO
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
tusharrs
Contributor
3230 Points
668 Posts
Re: File Info
May 02, 2012 10:51 AM|LINK
strOwner = fs.GetOwner(TypeOf(System.Security.Principal.NTAccount))
( Mark as Answer if it helps you out )
View my Blog
lordplazikov...
Member
195 Points
319 Posts
Re: File Info
May 02, 2012 10:53 AM|LINK
'NTAccount' is a type in 'Principal' and cannot be used as an expression
lordplazikov...
Member
195 Points
319 Posts
Re: File Info
May 02, 2012 11:04 AM|LINK
File.GetAccessControl(path).GetOwner(GetType(NTAccount)).Value
This is the solution now the file type.