System.IO.FileInfo and image attributes

Mondeo

Well-known member
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Im building a custom file browser for my application, I want to list certain files based on thier name so ive used io.directory.getfiles and filtered the results.

But In windows explorer ive noticed that certain files have extended attributes over and above thier standard read only, hidden etc etc.

For example jpegs have height and width. It would be great if I could read this information using something like io.fileinfo. Are these details actually embedded in the file itself and can they be read?

Thanks
 
How and where these types of details are stored depends on the file type. For JPEGs, the width and height are stored within the file. MP3s contain most of this type of extra data in ID3 tags within files. Some information for certain file types is stored in "alternate file streams," a feature of NTFS. So, as far as I know, there is no simple and standard technique that can be used in a general fasion to get this type of data from files.
 
What about jpegs? Is there an easy way to get that info, besides opening each file as an image and checking its height and width properties?
 
you need to be looking at " System.Drawing.Imaging.PropertyItem "
if you look at the Image class you will see that there is a field called
PropertyItems, eg:
Code:
        Dim img As Image = Image.FromFile("E:\Image1.jpg")
        For Each propItem As System.Drawing.Imaging.PropertyItem In img.PropertyItems
            /// here you can look at the value of each properyitem ( height , etc... )
            /// you need to determine what the value is ( string, byte, byte array, etc... by its ID )
            /// theres a list if ID tags on msdn here ---> [URL="http://msdn2.microsoft.com/en-us/library/system.drawing.imaging.propertyitem.id.aspx"]ID TAGS[/URL] <---
        Next
look for 0x0100 PropertyTagImageWidth in the list on the link --> ID TAGS <-- for example, that should show your image width, you can see every detail of an image using PropertyItems.
hope it helps :)
 
Back
Top