我在Windows窗体应用程序中有一个浏览按钮,我只想过滤选择PDF文件的选项。因此,在浏览文件窗口中,只有pdf文件可见,不会显示.doc或任何类型的文档格式。只允许上传pdf文件
private void btnSelectFile_Click(object sender, EventArgs e)
{
var dlg = new OpenFileDialog();
var res = dlg.ShowDialog();
if (res == DialogResult.OK)
{
DocumentUNCPath.Text = dlg.FileName;
}
}
这是一个重复的问题。与解释一起在这里看到答案。 http://stackoverflow.com/questions/2069048/setting-the-filter-to-an-openfiledialog-to-allow-the-typical-image-formats – 2013-02-13 14:25:48