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 from one directory to another (2) 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
30-Aug-02
Category
Files Operation
Language
Delphi All Versions
Views
72
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   var
3     sfos: TSHFileOpStruct;
4   begin
5     FillChar(sfos, SizeOf(sfos), 0);
6     dir := dir + '\*.*'#0;
7     dest := dest + '\*.*'#0;
8     with sfos do
9     begin
10      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 := nil
18    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.

			
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