Author: james Bond How to copy all Files inDirectory Answer: ...copy / move / delete whole directory? 1 uses 2 ShellApi; 3 4 function CopyDir(const fromDir, toDir: string): Boolean; 5 var 6 fos: TSHFileOpStruct; 7 begin 8 ZeroMemory(@fos, SizeOf(fos)); 9 with fos do 10 begin 11 wFunc := FO_COPY; 12 fFlags := FOF_FILESONLY; 13 pFrom := PChar(fromDir + #0); 14 pTo := PChar(toDir) 15 end; 16 Result := (0 = ShFileOperation(fos)); 17 end; 18 19 function MoveDir(const fromDir, toDir: string): Boolean; 20 var 21 fos: TSHFileOpStruct; 22 begin 23 ZeroMemory(@fos, SizeOf(fos)); 24 with fos do 25 begin 26 wFunc := FO_MOVE; 27 fFlags := FOF_FILESONLY; 28 pFrom := PChar(fromDir + #0); 29 pTo := PChar(toDir) 30 end; 31 Result := (0 = ShFileOperation(fos)); 32 end; 33 34 function DelDir(dir: string): Boolean; 35 var 36 fos: TSHFileOpStruct; 37 begin 38 ZeroMemory(@fos, SizeOf(fos)); 39 with fos do 40 begin 41 wFunc := FO_DELETE; 42 fFlags := FOF_SILENT or FOF_NOCONFIRMATION; 43 pFrom := PChar(dir + #0); 44 end; 45 Result := (0 = ShFileOperation(fos)); 46 end; 47 48 procedure TForm1.Button1Click(Sender: TObject); 49 begin 50 if cCopyDir('d:\download', 'e:\') = True then 51 ShowMessage('Directory copied.'); 52 end;