System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
dlg.AutoUpgradeEnabled = false;
dlg.Filter = "(*.jpg,*.png,*.jpeg,*.bmp,*.gif)|*.jgp;*.png;*.jpeg;*.bmp;*.gif|All files(*.*)|*.*";
dlg.FilterIndex = 1; //默认项
dlg.RestoreDirectory = true;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
//此处做你想做的事 ...=openFileDialog1.FileName;
}
‘|’分割的两个,一个是注释,一个是真的Filter,显示出来的是那个注释。如果要一次显示多中类型的文件,用分号分开