正则表达式在打开文件对话框中过滤文件 [英] Regular expression to filter files in OpenFileDialog

查看:140
本文介绍了正则表达式在打开文件对话框中过滤文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在打开文件对话框过滤文件(的WinForms)
基于正则表达式。文件都相同的扩展名(的.xml)。
大文件分割成几个文件具有相同的名称只与_1 ...
分开我们只希望显示文件,而不_1(第一个数据文件)

I would like to know how to filter files in a open file dialog (in winforms) based on a regular expression. Files have all same extensions (.xml). Big files are split up into several files with the same name only to be separated with _1 ... We only want to show the files without _1 (first data file)

打开文件对话框中有一个属性过滤器,但我不知道如何在我们的文件名格式,因此正则表达式中指定。

the open file dialog has a property filter but i dont know how to specify this in our filename format, hence the regular expression.

Thankx ,
尼基

Thankx, Niki

推荐答案

我不认为你可以做到这一点在打开文件对话框的过滤器属性,它只是筛选的基础上扩展名的文件列表。

I don't think you can do it with the OpenFileDialog's Filter property, which just filters list of files based on extension.

我想你必须让用户选择一个XML文件,验证,然后弹出的对话框再次,如果它是一个_1文件。您可以订阅FileOK事件和槽在这个验证在那里。您可以使用正则表达式来这里验证文件名。这是可以做的最好的..我猜。

I think you'll have to let the user choose an xml file, validate and then pop up the dialog again if its a _1 file. You can subscribe to the FileOK event and slot in this validation in there. You can use regular expressions to validate the filename here. That's the best that can be done.. I guess.

这篇关于正则表达式在打开文件对话框中过滤文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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