我正在成功地将图像缩略图加载到 ListView 控件中:
lsvImageThumbs.Items.Clear();
imgl_ImageThumbs.Images.Clear();
string[] files = Directory.GetFiles(@"C:\Documents and Settings\Etc\Desktop\Test");
for (int indexFiles = 0; indexFiles < files.Length; indexFiles++)
{
Image img = Image.FromFile(files[indexFiles]);
DirectoryInfo dinfo = new DirectoryInfo(files[indexFiles]);
imgl_ImageThumbs.Images.Add(dinfo.Name, img);
lsvImageThumbs.Items.Add(files[indexFiles], dinfo.Name, indexFiles);
}
然后我可以选择图像缩略图并希望将文件移动到目录:
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (ListViewItem items in lsvImageThumbs.SelectedItems)
{
//File.Copy(items.Name, dlg.SelectedPath + "\\" + items.Text);
File.Move(items.Name, dlg.SelectedPath + "\\" + items.Text);
MessageBox.Show(items.Text + " Taken");
}
}
File.Copy 工作没有问题,但对于 File.Move 我收到以下错误:
The process cannot access the file because it is being used by another process.