1

I found this post.

That explains how to get extended file properties in .net. But it points to a Code Project article that is 10 years old.

The thread itself is 5 years old.

Is there a better way now to get extended file properties like Title, SubTitle, Episode Name etc.?

What I would really like to do is to get the extended file information on individual files. It looks to me like this code loops through a directory and gets the file info on those files.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
spinnaker
  • 119
  • 3
  • 7

3 Answers3

1

I used already the Windows API Code Pack

ShellObject picture = ShellObject.FromParsingName(file);

var camera = picture.Properties.GetProperty(SystemProperties.System.Photo.CameraModel);
newItem.CameraModel = GetValue(camera, String.Empty, String.Empty);

var company = picture.Properties.GetProperty(SystemProperties.System.Photo.CameraManufacturer);
newItem.CameraMaker = GetValue(company, String.Empty, String.Empty);

Link to a Blogpost by Rob Sanders - [Link removed. It was pointing to malware.]

RandomEngy
  • 14,931
  • 5
  • 70
  • 113
SteMa
  • 421
  • 6
  • 13
  • There is also a NuGet-Package [WindowsAPICodePack-Core](https://www.nuget.org/packages/WindowsAPICodePack-Core) – SteMa Jul 24 '14 at 14:52
  • The link to the blogpost now redirects randomly to suspicious pages full of deceiving downloading links... – pasx Aug 11 '19 at 16:32
0

You can use my MetadataExtractor library to access all sorts of metadata from image and video files. It supports Exif, IPTC, and many other kinds of metadata.

It's available on GitHub and NuGet.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
0

In order to get this code to run you will need to add two nugget packages - I had to add older version from the package manager console as the latest version wouldn't install on my antediluvian VS 2012:

    Install-Package WindowsAPICodePack-Core -Version 1.1.2
    Install-Package WindowsAPICodePack-Shell -Version 1.1.1

Below is some code to list all the properties:

 using Microsoft.WindowsAPICodePack.Shell;

    private void ListExtendedProperties(string filePath)
    {
        var file = ShellObject.FromParsingName(filePath);
        var i = 0;
        foreach (var property in file.Properties.DefaultPropertyCollection)
        {
            var name = (property.CanonicalName ?? "unnamed-[" + i + "]").Replace("System.", string.Empty);
            var t = Nullable.GetUnderlyingType(property.ValueType) ?? property.ValueType;
            var value = (null == property.ValueAsObject)
                ? string.Empty
                : (Convert.ChangeType(property.ValueAsObject, t)).ToString();
            var friendlyName = property.Description.DisplayName;
            Console.WriteLine(i++ + " " + name + "/" + friendlyName + ": " + value);
        }
    }
pasx
  • 2,718
  • 1
  • 34
  • 26