如何过滤c#中没有扩展名的文件 [英] How to filter files with NO extension in c#

查看:423
本文介绍了如何过滤c#中没有扩展名的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过OpenFileDialog1.Filter =设置十六进制文件(*。)| *。;

但它没有显示任何文件。我想在Openfiledialog浏览器中显示没有扩展名的文件,

请告诉我有蚂蚁的想法。

I tried OpenFileDialog1.Filter = "Setting Hex files (*.)|*.";
but it showing no files.I want to show files having no extensions during Openfiledialog browser,
please tell me having ant idea.

推荐答案

使用未改变的OpenFileDialog框是不可能的 - 它需要一个扩展名,并且windows会删除。。从文件结束,所以*。永远不会工作。



你可以这样做,如果你可以挂钩标准对话框(见这里: http://msdn.microsoft.com/en-us/library/ms646960(VS.85).aspx [ ^ ],约1/3在过滤器下面的方式)但是在C#中为一个小功能做了很多工作!



你的Hex文件没有任何扩展名有什么好的理由?给它们一个像* .MyAppHex这样的名字或类似的东西然后过滤它们会容易得多。



如果你真的必须这样做,我会很想不使用标准盒子,但是自己重新创建它的功能 - 它可能比在标准对话框上实现挂钩要容易得多!
It''s not possible with an unaltered OpenFileDialog box - it expects an extension, and windows removes the "." from files end with it, so "*." will never work.

You could probably do it, if you can hook the standard dialog (see here: http://msdn.microsoft.com/en-us/library/ms646960(VS.85).aspx[^], about 1/3 the way down, under filters) but that''s a lot of work in C# for a small feature!

Is there any good reason why your Hex files have no extension? It would be a lot easier to give them a name like *.MyAppHex" or similar then filter for them.

If you really do have to do this, I would be tempted to not use the standard box at all, but re-create it''s features myself - it''s probably a lot easier than implementing the hooking on a standard dialog!


这篇关于如何过滤c#中没有扩展名的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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