【发布时间】:2018-02-16 10:24:17
【问题描述】:
我正在尝试使用我创建的自定义文件格式向我的 OpenFileDialog 添加过滤器这是我目前所拥有的:
private void btnSymKey_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "public key (*.publ)";
openFileDialog1.FilterIndex = 2;
if (openFileDialog1.ShowDialog() == true)
{
DecryptionPathes.encryptedKey = System.IO.Path.GetFullPath(openFileDialog1.FileName);
txtSymKeyPath.Text = DecryptionPathes.encryptedKey;
this.btnSafeDecrypt.Visibility = Visibility.Visible;
this.btnSafeDecrypt.IsEnabled = true;
this.txtSafeDecryptPath.Visibility = Visibility.Visible;
}
}
但这不起作用,因为 OpenFileDialog 不知道“.publ”是否还有过滤这些文件的方法?
【问题讨论】:
-
好的,我应该阅读例外情况......你必须写“你的文字 |*.yourFormat;”
标签: c# wpf openfiledialog