use*_*938 15 .net c# openfiledialog filter
是否可以指定自定义过滤器,如'ABC*.pdf',这意味着:"显示所有以ABC开头的PDF"?
我只能指定*.pdf,*.doc , . 等
谢谢弗洛里安
Kja*_*tan 27
Updated
Changed my solution a little, after realizing the following would be better. This is not a complete "hard filter", but making use of the FileName property should basically give you what you need;
using System;
using System.Windows.Forms;
namespace TestingFileOpenDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.openFileDialog1.FileName = "pro*";
this.openFileDialog1.Filter = "Pdf Files|*.pdf";
this.openFileDialog1.ShowDialog();
}
}
}
Run Code Online (Sandbox Code Playgroud)
I suppose this might depend on which OS you are working with, but it did work in my case any way, on Windows 8.
I also realize that this does not filter out all irrelevant files "permanently", but it does at least provide an initial filter.
Result:

如果没有pro*在FileName字段中,这将显示其他几个PDF文件.