【发布时间】:2019-09-18 00:28:35
【问题描述】:
我正在尝试使用 C# 中的 Shell32 确定视频文件的分辨率,但属性返回空字符串,尽管 Windows shell 可以正常显示信息。
请注意,我不能为此任务合并任何第三方库(DirectShow 或其他)。
对于不同的视频文件,此行为仍然存在。很遗憾,here 中提供的答案都没有帮助。
我正在使用以下代码提取信息:
Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder objFolder;
objFolder = shell.NameSpace(Path.GetDirectoryName(videoFile.FullName));
FolderItem objFile = objFolder.ParseName(videoFile.Name);
List<string> arrHeaders = new List<string>();
for (int i = 0; i < 1000; i++) {
string header = objFolder.GetDetailsOf(null, i);
if (String.IsNullOrEmpty(header))
continue;
arrHeaders.Add(header);
}
var length = objFolder.GetDetailsOf(
objFile, arrHeaders.FindIndex(h => h == "Length"));
var resWidth = objFolder.GetDetailsOf(
objFile, arrHeaders.FindIndex(h => h == "Frame width"));
var resHeight = objFolder.GetDetailsOf(
objFile, arrHeaders.FindIndex(h => h == "Frame height"));
对于以下文件,我希望 resWidth 具有值 "1920" 和 resHeight 具有值 "1080" 但它们都包含空字符串。这两个属性都存在于arrHeaders 中,特别是在我系统上的索引 301 和 303 中。
附带说明,Length 属性按预期工作。
【问题讨论】:
-
您确定this answer 没有帮助吗?
标签: c# windows windows-10 shell32 extended-properties