I need to extract the date from the "Media Created" column (highlighted in green in my the example photo below) using C#.
In my example, the "Media Created" and "Date" columns are the exact same. However, there are several instances where they are not. The "Media Created" column contains the correct date for when the video was actually recorded.
Here is the function I used to get it. Thanks to Aziz for pointing me in the right direction:
Shell shell = new ShellClass();
Folder folder = shell.NameSpace(_File.DirectoryName);
FolderItem file = folder.ParseName(_File.Name);
// These are the characters that are not allowing me to parse into a DateTime
char[] charactersToRemove = new char[] {
(char)8206,
(char)8207
};
// Getting the "Media Created" label (don't really need this, but what the heck)
string name = folder.GetDetailsOf(null, 191);
// Getting the "Media Created" value as a string
string value = folder.GetDetailsOf(file, 191).Trim();
// Removing the suspect characters
foreach (char c in charactersToRemove)
value = value.Replace((c).ToString(), "").Trim();
// If the value string is empty, return DateTime.MinValue, otherwise return the "Media Created" date
return value == string.Empty ? DateTime.MinValue : DateTime.Parse(value);
The extended file properties can be obtained by using Folder.GetDetailsOf() method. As per this thread, the Media Created Date can be retrieved using a property id of 177.
There are another way to retrieve data, using the Microsoft.WindowsAPICodePack.Shell namespace.
ShellObject shell = ShellObject.FromParsingName(path);
var data = shell.Properties.System.Media.DateEncoded;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With