Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

7 thoughts on “Extracting file metadata with C# and the .NET Framework

  • Dale Bartlett

    Hi Rob, very helpful code, thank you. I would like to enumerate all the properties of a file but have been unable to either hit the right foreach, nor find any examples. Do you have any suggestions? Regards, Dale

    • Rob Sanders Post author

      Hi Dale,

      Sorry for the delayed response.

      The main problem I can see you’ll have is that there are quite a lot of potential file metadata types. Purely from a performance point of view, it’ll be far easier to query the extended data if you know the base type of the file (even if you judge it based off the file extension) than it is to sort of generically process the file.

      Otherwise, another approach could be to just query a pool of extended properties for each file, and drill down where you need to for specific types of files.



  • Ray Red

    Hi, this sample has worked perfectly for me. Thank you. I do have one question however, I can return all metadata values except for the Latitude and Longitude values.
    string longitude = GetValue(picture.Properties.GetProperty(SystemProperties.System.GPS.Longitude));
    Would you know why?

        • Rob Sanders Post author

          I’ll take a look and see if I can repro. What sort of filetype are you running against? If you’d be able to email me some test data, that’d be great (see About Rob for info).