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 copy all Files in 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
20-Apr-04
Category
Files Operation
Language
Delphi All Versions
Views
225
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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;


			
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