Accessing file extended properties.

D

daveh551

Many types of files have a number of "extended properties" beyond the
basic file size, creation time, modified time, accessed time, etc.
For example (the one I am particularly interested in), image files
(jpg, etc.) have a dimensions (H x W in pixels) attribute, etc. These
attributes are readily available to the operating system - just hover
your mouse pointer over the thumbnail of an image file in the
directory, and it will come up with the dimensions as well as some
other properties.

I found the following link http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_lunl.mspx?mfr=true
related to the windows scripting engine in Windows 2000 that lists the
extended attributes that are stored. In the following code,
originally written in VB6 and upgraded to VB.NET, these properties can
be extracted:

Dim objShell as Object
Dim objFolder as Object
Dim strDimensions as Object

objShell = CreateObject("Shell.Application")
objFolder = objShell.Namespace("C:\temp"); ' path to the folder
containing the file
strDimensions = objFolder.GetDetailsOf(objFolder.ParseName
("test.jpg"), 26)

This code will set strDimensions to "3008 x 2000", or whatever the
dimensions of the file are.

Now, for my question: I have searched and searched and searched all
the help files and forums and other documentation I can think of for
some managed code (.NET) equivalent to this functionality without
resorting to creating an unmanaged object to invoke the shell
scripting engine, and I have not been successful. Surely something
this basic is available somehow?

Does anyone know how to do this in C#?

Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top