delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
493 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


synchronise a directory including all sub directories Format this article printer-friendly!Bookmark function is only available for registered users!
simple procedure to update files in a directory with files from a source directory
Product:
Delphi 5.x (or higher)
Category:
Files Operation
Skill Level:
Scoring:
Last Update:
06/11/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet directory synchronise synchronize file files network template templates directories across disk copy
Times Scored:
4
Visits:
1510
Uploader: jurriaan cap
Company: Gemeente Venhuizen
Reference: Jurriaan Cap
 
Question/Problem/Abstract:
you want to have a directory that is always updated with the latest files from a source directory

for instance a template directory
Answer:




uses filectrl


procedure tform1.synchronisedirectory(frompath, topath : string );
var
sr : tsearchrec ;
r :  integer ;
begin
application.processmessages;
r := findfirst(frompath + '\*.*', faanyfile, sr);
while r = 0 do
begin
    if (sr.name <> '.') and (sr.name <> '..') then
    begin
      if (sr.attr <> 0) and (fadirectory <> 0) then
     begin
     synchronisedirectory(frompath + '\'+sr.name , topath + '\' + sr.name)
     end ;
      if not directoryexists(topath) then
      begin
      forcedirectories(topath);
      end;
     {Version control}
     if fileage(frompath + '\' + sr.name) <> fileage(topath + '\' + sr.name)then
      begin
      CopyFile(pchar(frompath + '\' + sr.name),pchar(topath + '\' + sr.name),FALSE);
      
      end;
     end;
    r := findnext(Sr)
end;
findclose(sr);

end;

just start the procedure with a source directory and a target directorie and the files that are different in the target directory wil be updated , directories will be created and stuff.

this program will not however remove directories and files from the target directory if they are not present in the source directory.

to implement that you could use the same procedure and and do it vica versa with remove file functions instead.

this works in delphi 5 but should also work in lower versions






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
good
    Eber Irigoyen (Jun 11 2001 9:17AM)

simple and nice, works good
=o)
salu2
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
L. Rosenstein
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)