我怎样才能提取之日起,"介质上创建"一视频文件的列? [英] How can I extract the date from the "Media Created" column of a video file?

查看:206
本文介绍了我怎样才能提取之日起,"介质上创建"一视频文件的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提取的日期媒体创建一栏使用C#(以绿色突出显示在我下面的示例照片)。

在我的例子中,媒体创建和日期列是完全一样的。然而,有几种情况下它们不是。 媒体创建列中包含正确的日期时,实际上是录制的视频的。

下面是我用得到它的功能。感谢阿齐兹指着我的方向是正确的:

 壳牌=新ShellClass();
文件夹文件夹= shell.NameSpace(_File.DirectoryName);
的FolderItem文件= folder.ParseName(_File.Name);

//这些是不是让我来解析成一个DateTime字符
的char [] charactersToRemove =新的char [] {
    (焦)8206,
    (焦)8207
};

//获取媒体创建标签(并不真正需要这个,但是什么)
字符串名称= folder.GetDetailsOf(NULL,191);

//获取媒体创建值作为一个字符串
字符串值= folder.GetDetailsOf(文件191).Trim();

//删除可疑人物
的foreach(在charactersToRemove字符C)
    值= value.Replace((C)的ToString(),).Trim();

//如果该值的字符串为空,返回DateTime.MinValue,否则返回媒体创建日期
返回值==的String.Empty? DateTime.MinValue:DateTime.Parse(值);
 

解决方案

扩展文件属性可以使用的 Folder.GetDetailsOf()方法。 按本线程,在媒体创建日期可以使用177的属性ID进行检索。

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.

这篇关于我怎样才能提取之日起,"介质上创建"一视频文件的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆