选择多个文件并加载显示listbox
选择多个文件并加载显示listbox环境:WIN7 + Halcon12 + x86 + VS2013
List<string> ImagePaths = new List<string>();
string ImagePath = null;
string ImagePathWithName = null;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = true;//可以选择多个选项
//openFileDialog.Filter = "JPEG文件|*.jpg*|BMP文件|*.bmp*|TIFF文件|*.tiff*";
openFileDialog.Filter = "所有图像文件 | *.bmp; *.pcx; *.png; *.jpg; *.gif;*.tif; *.ico; *.dxf; *.cgm; *.cdr; *.wmf; *.eps; *.emf";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
foreach (string singleImagepath in openFileDialog.FileNames)
{
//选择了shape文件后
ImagePath = System.IO.Path.GetDirectoryName(singleImagepath);
ImagePathWithName = singleImagepath;
ImagePaths.Add(ImagePathWithName);
//this.listBox1.Items.Add(ImagePathWithName);
}
this.listBox1.DataSource = ImagePaths;
//HTuple ImagePath = openFileDialog.FileName;
//HOperatorSet.ReadImage(out ho_image, ImagePath);
}
页:
[1]