
private void From1_Load(object sender, EventArgs e)
{
//获取PhotoPath
string path = @"Files\pic\";
var allFilesPath = Directory.GetFiles(path);
//显示在listbox1中
listBox1.DataSource= allFilesPath;
}
private void btnImport_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "JPG文件(*jpg)|(*.jpg)|JPEG文件(*.jpeg)|(*.jpeg)|BMP文件(*.bmp)|(*.bmp)|图标(*.ico)|(*.ico)";
}
{
//获取PhotoPath
string path = @"Files\pic\";
var allFilesPath = Directory.GetFiles(path);
//显示在listbox1中
listBox1.DataSource= allFilesPath;
}
private void btnImport_Click(object sender, EventArgs e)
{
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "JPG文件(*jpg)|(*.jpg)|JPEG文件(*.jpeg)|(*.jpeg)|BMP文件(*.bmp)|(*.bmp)|图标(*.ico)|(*.ico)";
}
操作:点下按钮选择导入的图片,然后把这些图片的名称显示在ListBox控件中。谢谢。