Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to save a complete directory Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-Oct-02
Category
Files Operation
Language
Delphi 2.x
Views
64
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   var
3     OpStruc: TSHFileOpStruct;
4     frombuf, tobuf: array[0..128] of Char;
5   begin
6     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 do
11    begin
12      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.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC