Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup routines with MkDir etc

Status
Not open for further replies.

Guthro

Technical User
Sep 9, 2006
107
0
0
GB
I manually back up files in an old invoicing system. I locate 8 or 10 files, copy them, then create a directory of the day's date, and paste the files there on another pc or cd etc. If a new month turns, then I create a directory for the month.
So I have BackupDirectory / Month/ Date/ files

Using Delphi examples I can get a simple form up and create a directory and get a warning up it the directory already exists. Ideally I'd like to create an app that does it all automatically but putting my logic down to work in Delphi pascal never works. A bit like humming a song in your head and then try to sing it. Its never the same !

So, using my garbled logic..
If the month is February and February Directory doesn't exist, create it.
Move to that directory ChDir(currentmonth.
Use MkDir(todaydate) to create a directory with the current date within the currentmonth directory.
Connect via a Lan or mapped drive and select a know list of files and copy them. Or test for files of a given extension if the file date is the current date.
Then paste them to the above created todaydate dorectory.

Is anyone able to put that garbled logic into some sort of delphi pascal routine or atleast give me a few pointers.

Thanks.


My Feeblegirl.com Forum boards for mmorpgs, sport, fun, politics...
 
What you have already is a good basis but there are more points to consider. What do you want to happen if the target LAN folder does not exist at the time of transfer?Abandon it altogether, or keep trying, how many times, how often, several possibilities here. What if you need to change to target folder or the location of the files being backed up? Also you might want to check to make sure the files have actually been written.

The reason I am asking this is because I have built an entire application around this concept, so I know how complex it can get when you start thinking of all the possibilities.

My app is based around the 'copyfile' function I use the version in Demos/docs/Fmxutils, but you can use the API call directly.

Look at the Date/Time functions list in the Delphi help to see how you can convert dates and times to strings and manipulate them to get your folder names.








Steve [The sane]: Delphi a feersum engin indeed.
 
Add "FileCtrl" to your uses clause and use built in Delphi functions ForceDirectories and SelectDirectory. The help files contain excellect explanations and examples of how to use these tools.

HTH

Roo
Delphi Rules!
 
Thanks for the replies. Sorry I've not answered before, I got sidetracked.

I hadn't even heard of the ForceDirectories function before ! What a handy little routine.

My Feeblegirl.com Forum boards for mmorpgs, sport, fun, politics...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top