Question Getting file details

nineclicks

Member
Joined
Jun 13, 2013
Messages
18
Programming Experience
Beginner
I'm trying to get file details from pictures and videos such as width and height without having to actually open the file. I plan on indexing a lot of files at once so if I could just grab the file details like the ones in a files properties menu that would help a lot. I know they are labeled differently for different files. Some are width and height, some are frame width and frame height.

Whenever I try to find information about this it always involves loading the file as a bitmap. Surely there is a way to just read the file details?

Thanks.
 
Last edited:
VB.NET:
    Dim fi As New FileInfo(fileName)
    Dim shl As Shell32.Shell = New Shell32.Shell
    Dim dir As Shell32.Folder = shl.[NameSpace](fi.DirectoryName)
    Dim itm As Shell32.FolderItem = dir.Items().Item(fi.Name)
    Dim itm2 As Shell32.ShellFolderItem = DirectCast(itm, Shell32.ShellFolderItem)

    Dim IDdimensions as Integer

            For i As Short = 0 To 400
                Dim name As String = dir.GetDetailsOf(dir.Items, i)
                If name.ToLower = "dimensions" Then IDdimensions = i
                If name = "" Then Exit For
            Next


    Dim str As String = dir.GetDetailsOf(itm2, IDdimensions )

Took me some time to figure it out but I finally did. It looks like the numbers of each detail may be different for different people, I found someone who posted a lit of their and it was different from mine slightly. So there's a bit in there to get the detail by name and you can just add more to get more detail numbers. I declared the variables globally and set them to -1 so that it only has to do this once.
 
Back
Top