0

所以我有一个小问题,我的程序找到并将特定文件(例如 Mp3、wmv 等)写入 CheckBoxList,然后我想选择部分或全部文件将这些文件传输到我选择的目录。问题是我不知道如何只移动选定的文件?

下面是一些代码:

procedure TfrMain.Button2Click(Sender: TObject);
var
  dirName : String;
begin
dirName := Edit3.Text;
  CreateDir(dirName);
if DirectoryExists(dirName) then MoveFile(PChar(Path), PChar(DirName));
end;

procedure TfrMain.CheckBox2Click(Sender: TObject);
begin
if CheckBox2.Checked = true then CheckListBox1.SelectAll;
end;

提前致谢。

4

1 回答 1

2

您需要遍历列表,然后测试是否检查了每个项目。

for i := 0 to CheckListBox1.Count-1 do
  if CheckListBox1.Checked[i] then 
    // do something with the item
于 2013-08-18T12:48:13.637 回答