如何根据文件内容过滤OpenFileDialog中的文件? [英] How do I filter files in an OpenFileDialog based on the contents of the file ?

查看:48
本文介绍了如何根据文件内容过滤OpenFileDialog中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#和.Net框架的新手,想知道我是否可以就这一特定主题提出一些建议,



我的要求是,我需要为我的应用程序使用OpenFileDialog,但其行为略有不同。我有自定义扩展名为* .sda的文件,这些sda文件也有与之关联的版本。版本是文件的前4个字节。但是,不考虑版本号,它们都具有相同的扩展名sda。



如果我使用sda扩展名过滤文件,OpenFileDialog会显示所有SDA文件。我想改变它的行为,它读取SDA文件的版本号,并只显示特定版本的SDA文件。因此,这是一个基于内容而不是扩展名来过滤文件的问题。



如何实现这一目标?任何想法都表示赞赏。

请原谅我可怜的英语....

Hi, I am quite new to C# and the .Net framework and was wondering if I can get some advise on this particular topic,

My requirement is that, I need to have an OpenFileDialog for my application, but with a slight difference in its behavior. I have files with a custom extension as *.sda, also these sda files have versions associated with them. The versions are the first 4 bytes of the files. However, without regard to the version number they all have the same extension sda.

If I filter the files with sda extension, OpenFileDialog shows all SDA files. I would like to alter its behavior where it reads the version number of the SDA files and displays only a particular versioned SDA files. Thus, it is a question of filtering files based on their content and not on their extension.

How about achieving this ? Any ideas are appreciated.
Pardon my poor English....

推荐答案

我很确定这不能做到。 OpenFileDialogue在文件过滤器方面非常简单。



您必须进行自定义对话才能执行目录文件搜索。您可以使它非常基本,因为您不需要OpenFileDialogue为您提供的所有额外功能。
I'm pretty sure that this cannot be done. The OpenFileDialogue is very set-in-its-ways when it comes to file filters.

You will have to make a custom dialogue that performs the directory file search for you. You can make it pretty basic as you won't need all the extra functionality that the OpenFileDialogue presents you with.


这篇关于如何根据文件内容过滤OpenFileDialog中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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