简体   繁体   English

.NET-如何获取所有视频格式,而不是指定每种格式

[英].NET - How to get all video formats instead of specifying each format

How to get all document formats instead of specifying explicitly (ie -> .pdf, .doc etc) ? 如何获取所有文档格式而不是明确指定(即-> .pdf,.doc等)?

Similarly, how do I get all video formats instead of specifying explicitly all video formats? 同样,如何获取所有视频格式,而不是明确指定所有视频格式?

OpenFileDialog ofd = new OpenFileDialog();

ofd.filter = "DOCUMENT|*.pdf";  //filter document without giving all formats explicitly.

The filter mechanism works by file extension only. 筛选器机制仅通过文件扩展名起作用。 You can list multiple extensions per group and break the list into multiple groups like this: 您可以按组列出多个扩展名,并将列表分成多个组,如下所示:

.Filter = "Video Files (*.avi, *.mp4)|*.avi;*.mp4|Document Files (*.pdf, *.doc, *.docx, *.txt)|*.pdf;*.doc;*.docx;*.txt|All Files (*.*)|*.*"

But this will always require you to be explicit about the exact list of file extensions you want to support. 但这总是需要您明确说明要支持的文件扩展名的确切列表。

You can construct the Filter definition string programmatically, so if you're hoping to somehow locate all files with the same class (according to the shell) or mime type , then you'll have to create a filter from some authoritative source of your choosing. 您可以通过编程方式构造Filter定义字符串,因此,如果您希望以某种方式找到所有具有相同 (根据shell)或mime type的文件 ,那么您将不得不从您选择的一些权威来源中创建一个过滤器。 Possibly either by probing the system registry , or by using an up-to-date mime type map . 可能是通过探测系统注册表 ,或者是使用最新的mime类型映射表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM