dcDiskScanner是遍历文件夹的组件
1、设置属性并执行
if Self.CheckBox1.Checked then Self.dcDiskScanner1.IncludeSubfolders:=True;//是否包含子文件夹 if Self.dcFolderEdit1.Text<>'' then Self.dcDiskScanner1.Folder:=Self.dcFolderEdit1.Text;//要扫描的目标文件夹 Self.dcDiskScanner1.Execute;//执行
2、文件已找到触发时间dcDiskScanner1FileFound:
procedure TForm1.dcDiskScanner1FileFound(Sender: TObject; const FileName, FileType: String; const FileSize: Extended; const FileTime: TDateTime; const FileAttributes: TdcScanAttributes; const LargeIcon, SmallIcon: TIcon; SysImageIndex, TotalFiles: Integer; const TotalSize: Extended);beginSelf.CheckListBox1.Items.Add(FileName);//一旦找到文件就加入checklistbox1列表中end;