I'm writing something that moves images/videos captured off a camera or smart phone. So there is a mix of .jpg from camera or smartphone, .mov files (iphone movies), .png (screen caps etc).
In the first instance want a file created time (as opposed to file write time).
I found in the examples how to pull a specific value from a jpg:
IEnumerable<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(filename);
var subIfdDirectory = directories.OfType<MetadataExtractor.Formats.Exif.ExifSubIfdDirectory>().FirstOrDefault();
var dateTime = subIfdDirectory?.GetDescription(MetadataExtractor.Formats.Exif.ExifSubIfdDirectory.TagDateTimeOriginal);
and I found how to get it from a .MOV file
var subIfdDirectory = directories.OfType<MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory>().FirstOrDefault();
var dateTime3 = subIfdDirectory?.GetDescription(MetadataExtractor.Formats.QuickTime.QuickTimeTrackHeaderDirectory.TagCreated);
But it all seems a little clunky to have to determine the specific format, and then pull the specific tag directory.
Is there a more generic:
IEnumerable<MetadataExtractor.Directory> directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(filename);
var dateTime = directories.GetTag(TagDateTimeOriginal)
if (dateTime != null) <use value here>
dateTime = directories.GetTag(TagCreated)
if (dateTime != null) <use value here>
Or are there other examples that may be closer than my original code.