Author: Jonas Bilinkevicius
Is there an API function which gives all the subdirectories and all the files of
one particular directory (in order to save a whole directory for example )?
Answer:
You can copy a whole directory with one instruction using the ShFileOperation API
function:
1 procedure TForm1.Button2Click(Sender: TObject);
2 var3 OpStruc: TSHFileOpStruct;
4 frombuf, tobuf: array[0..128] of Char;
5 begin6 FillChar(frombuf, Sizeof(frombuf), 0);
7 FillChar(tobuf, Sizeof(tobuf), 0);
8 StrPCopy(frombuf, 'd:\brief\*.*');
9 StrPCopy(tobuf, 'd:\temp\brief');
10 with OpStruc do11 begin12 Wnd := Handle;
13 wFunc := FO_COPY;
14 pFrom := @frombuf;
15 pTo := @tobuf;
16 fFlags := FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
17 fAnyOperationsAborted := False;
18 hNameMappings := nil;
19 lpszProgressTitle := nil;
20 end;
21 ShFileOperation(OpStruc);
22 end;
If you need a list of all files and subdirs you have to do a recursive scan using FindFirst/ FindNext.