Author: Tomas Rutkauskas
I would like to copy my work directory to H:\Backups and rename it to today's date,
eg: H:\Backups\030801\
Answer:
1 procedure CopyTree(dir, dest: string);
2 var3 sfos: TSHFileOpStruct;
4 begin5 FillChar(sfos, SizeOf(sfos), 0);
6 dir := dir + '\*.*'#0;
7 dest := dest + '\*.*'#0;
8 with sfos do9 begin10 wnd := 0;
11 wfunc := FO_COPY;
12 pFrom := PChar(dir);
13 pTo := PChar(dest);
14 fFlags := FOF_ALLOWUNDO or FOF_RENAMEONCOLLISION or FOF_SIMPLEPROGRESS;
15 fAnyOperationsAborted := false;
16 hNameMappings := nil;
17 lpszProgressTitle := nil18 end;
19 SHFileOperation(sfos)
20 end;
Create the destination directory with MkDir or ForceDirectories and call
21 22 CopyTree('c:\workdir', 'h:\backup\030801');
This will copy eventual subdirectories of c:\workdir too.