我正在尝试添加过滤器OpenFileDialog
控件,但是在使用过滤器之后。没有文件,只有文件夹。没有过滤器,一切正常。我能做些什么?
private void button1_Click(object sender, EventArgs e) {
OpenFileDialog fileChooser = new OpenFileDialog();
fileChooser.Filter = " Image File (*.jpeg)|(*.jpeg)| All Files (*.*) |(*.*)";
if (fileChooser.ShowDialog() == DialogResult.OK) {
pictureBox1.ImageLocation = fileChooser.FileName;
}
}
只是在定义文件扩展名时不要使用方括号。
fileChooser.Filter = "Image File (*.jpg)|*.jpg;*.jpeg|All Files|*.*";
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句