Click here to Skip to main content
13,007,145 members (60,540 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.4K views
5 bookmarked
Posted 23 Mar 2010

Obtain file properties from shell using ExtraPropertiesProvider class

, 25 Mar 2010
Rate this:
Please Sign up or sign in to vote.
ExtraPropertie...
ExtraPropertiesProvider obtain properties of a file using IShellFolder2, so you can get properties without parsing them yourself. To obtain a property, you need a file and a property key. A list of possible(but not all) property keys can be found in:

  • SummaryInformation
  • DocSummaryInformation
  • ImageSummaryInformation
  • MusicSummaryInformation
  • VideoSummaryInformation


You can use GetCollumnInfo() method to obtain a list of property keys in a specific folder as well.

string file = "c:\yourpicture.bmp";
string ext = PathEx.GetExtension(file);
 
string imageFilter = ".jpg,.jpeg,.png,.gif,.bmp,.pcx.tiff";
 
if (imageFilter.IndexOf(ext) != -1)
  foreach (string key in ImageSummaryInformation.PropertyDic.Keys)
  {
     PropertyKey propKey = ImageSummaryInformation.PropertyDic[key];
     Debug.WriteLine("{0} = {1}", key, ExtraPropertiesProvider.GetProperty(file, ref propKey);
  }


This will return all known properties, and their values:

foreach (CollumnInfo col in ExtraPropertiesProvider.GetCollumnInfo(file.Parent))
                if (col.CollumnName != "")
                {
                    PropertyKey propKey = col.PropertyKey;
                    object obj = ExtraPropertiesProvider.GetProperty(file, ref propKey);
                    if (obj != null)
                        Console.WriteLine(col.CollumnName + " - " + obj.ToString());
                }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170628.1 | Last Updated 25 Mar 2010
Article Copyright 2010 by Leung Yat Chun
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid