【发布时间】:2015-10-22 05:21:43
【问题描述】:
在 C# 中,我需要知道如何使用 checkListBox 中的项目名称作为文件路径,以便用户可以选择文件名,然后单击一个按钮,将这些文件移动到电脑上的另一个文件位置。我已经知道如何让文件出现在checkListBox 中,但我不知道如何检测checkListBox 中的文件路径,以便用户可以移动checkListBox 中列出的选定文件。
如果有帮助,这是一种更好的表达方式。我想在列表框中获取列出的文件,然后对它们做一些事情。
void sendbtn_Click(object sender, EventArgs e)
{
string destinationFolder = gamedir.Text;
string[] files = Directory.GetFiles(checkListView1.SelectedItems);
foreach(var file in files)
{
string destinationPath = Path.Combine(destinationFolder, file);
File.Copy(file.Fullname, destinationPath);
}
}
【问题讨论】:
-
你能发布一些代码吗?这总是有帮助的:)
标签: c# file checklistbox