Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
backup/restoration of files Posted by sarkiemarkie on 12 Feb 2006 at 7:35 AM
i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?

Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.

HELP


Report
Re: backup/restoration of files Posted by zibadian on 12 Feb 2006 at 10:03 AM
: i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
:
: Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
:
: HELP
:
:
:
You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
  Source := TFileStream.Create(SourceFileName, fmOpenRead);
  Dest := TFileStream.Create(DestFileName, fmCreate);
  Dest.CopyFrom(Source, Source.Size);
  Dest.Free;
  Source.Free;

Report
Re: backup/restoration of files Posted by sarkiemarkie on 14 Feb 2006 at 10:38 AM
: : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: :
: : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: :
: : HELP
: :
: :
: :
: You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
:
:   Source := TFileStream.Create(SourceFileName, fmOpenRead);
:   Dest := TFileStream.Create(DestFileName, fmCreate);
:   Dest.CopyFrom(Source, Source.Size);
:   Dest.Free;
:   Source.Free;
: 

:


How does the copyfile() API function work
Report
Re: backup/restoration of files Posted by zibadian on 14 Feb 2006 at 10:42 AM
: : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : :
: : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : :
: : : HELP
: : :
: : :
: : :
: : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: :
: :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: :   Dest := TFileStream.Create(DestFileName, fmCreate);
: :   Dest.CopyFrom(Source, Source.Size);
: :   Dest.Free;
: :   Source.Free;
: : 

: :
:
:
: How does the copyfile() API function work
:
You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
Report
Re: backup/restoration of files Posted by sarkiemarkie on 14 Feb 2006 at 11:04 AM
: : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : :
: : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : :
: : : : HELP
: : : :
: : : :
: : : :
: : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : :
: : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : :   Dest.CopyFrom(Source, Source.Size);
: : :   Dest.Free;
: : :   Source.Free;
: : : 

: : :
: :
: :
: : How does the copyfile() API function work
: :
: You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
:
can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
Report
Re: backup/restoration of files Posted by zibadian on 14 Feb 2006 at 11:58 AM
: : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : :
: : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : :
: : : : : HELP
: : : : :
: : : : :
: : : : :
: : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : :
: : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : :   Dest.CopyFrom(Source, Source.Size);
: : : :   Dest.Free;
: : : :   Source.Free;
: : : : 

: : : :
: : :
: : :
: : : How does the copyfile() API function work
: : :
: : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: :
: can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
:
The following code should copy (and overwrite existing) on the a:-drive:
  CopyFile('members.dat', 'a:\members.dat', true);

Report
Re: backup/restoration of files Posted by sarkiemarkie on 14 Feb 2006 at 12:13 PM
This message was edited by sarkiemarkie at 2006-2-14 12:17:34

: : : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : : :
: : : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : : :
: : : : : : HELP
: : : : : :
: : : : : :
: : : : : :
: : : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : : :
: : : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : : :   Dest.CopyFrom(Source, Source.Size);
: : : : :   Dest.Free;
: : : : :   Source.Free;
: : : : : 

: : : : :
: : : :
: : : :
: : : : How does the copyfile() API function work
: : : :
: : : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: : :
: : can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
: :
: The following code should copy (and overwrite existing) on the a:-drive:
:
:   CopyFile('members.dat', 'a:\members.dat', true);
: 

:

is there any way to choose the place instead of hard coding it. Like choosing the place at run time



Report
Re: backup/restoration of files Posted by zibadian on 14 Feb 2006 at 1:13 PM
This message was edited by zibadian at 2006-2-14 13:20:36

: This message was edited by sarkiemarkie at 2006-2-14 12:17:34

: : : : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : : : :
: : : : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : : : :
: : : : : : : HELP
: : : : : : :
: : : : : : :
: : : : : : :
: : : : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : : : :
: : : : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : : : :   Dest.CopyFrom(Source, Source.Size);
: : : : : :   Dest.Free;
: : : : : :   Source.Free;
: : : : : : 

: : : : : :
: : : : :
: : : : :
: : : : : How does the copyfile() API function work
: : : : :
: : : : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: : : :
: : : can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
: : :
: : The following code should copy (and overwrite existing) on the a:-drive:
: :
: :   CopyFile('members.dat', 'a:\members.dat', true);
: : 

: :
:
: is there any way to choose the place instead of hard coding it. Like choosing the place at run time
:
:
Of course: using variables, or string properties from things like edit boxes, save and open dialogs, comboboxes, etc. You asked for an example, which you got based on the filename you gave. Remember that parameters don't necessarily be hard-coded.

See also this thread:
http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=4&MsgID=324987
Report
Re: backup/restoration of files Posted by sarkiemarkie on 14 Feb 2006 at 1:23 PM
: : This message was edited by sarkiemarkie at 2006-2-14 12:17:34

: : : : : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : : : : :
: : : : : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : : : : :
: : : : : : : : HELP
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : : : : :
: : : : : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : : : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : : : : :   Dest.CopyFrom(Source, Source.Size);
: : : : : : :   Dest.Free;
: : : : : : :   Source.Free;
: : : : : : : 

: : : : : : :
: : : : : :
: : : : : :
: : : : : : How does the copyfile() API function work
: : : : : :
: : : : : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: : : : :
: : : : can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
: : : :
: : : The following code should copy (and overwrite existing) on the a:-drive:
: : :
: : :   CopyFile('members.dat', 'a:\members.dat', true);
: : : 

: : :
: :
: : is there any way to choose the place instead of hard coding it. Like choosing the place at run time
: :
: :
: Of course: using variables, or string properties from things like edit boxes, save and open dialogs, comboboxes, etc. You asked for an example, which you got based on the filename you gave. Remember that parameters don't necessarily be hard-coded.
:
you know if i put in an editbox, is there a way to bring up a little browse box in which the user can select a filepath? and then copy it
Report
Re: backup/restoration of files Posted by zibadian on 14 Feb 2006 at 2:55 PM
: : : This message was edited by sarkiemarkie at 2006-2-14 12:17:34

: : : : : : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : : : : : :
: : : : : : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : : : : : :
: : : : : : : : : HELP
: : : : : : : : :
: : : : : : : : :
: : : : : : : : :
: : : : : : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : : : : : :
: : : : : : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : : : : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : : : : : :   Dest.CopyFrom(Source, Source.Size);
: : : : : : : :   Dest.Free;
: : : : : : : :   Source.Free;
: : : : : : : : 

: : : : : : : :
: : : : : : :
: : : : : : :
: : : : : : : How does the copyfile() API function work
: : : : : : :
: : : : : : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: : : : : :
: : : : : can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
: : : : :
: : : : The following code should copy (and overwrite existing) on the a:-drive:
: : : :
: : : :   CopyFile('members.dat', 'a:\members.dat', true);
: : : : 

: : : :
: : :
: : : is there any way to choose the place instead of hard coding it. Like choosing the place at run time
: : :
: : :
: : Of course: using variables, or string properties from things like edit boxes, save and open dialogs, comboboxes, etc. You asked for an example, which you got based on the filename you gave. Remember that parameters don't necessarily be hard-coded.
: :
: you know if i put in an editbox, is there a way to bring up a little browse box in which the user can select a filepath? and then copy it
:
You could place a "Browse" button (as seen in many programs) next to the edit box. In the OnClick() you can place a code like this:
  if SelectDirectory('Select a folder', 'C:\', s) then
    EditBox1.Text := s;

With a little more coding, you can also use a TOpenDialog instead.
Report
Re: backup/restoration of files Posted by sarkiemarkie on 15 Feb 2006 at 3:30 AM
This message was edited by sarkiemarkie at 2006-2-15 3:31:0

: : : : This message was edited by sarkiemarkie at 2006-2-14 12:17:34

: : : : : : : : : : i know that to create a backup, i could make a new file identical to the onw i want to copy and then actually gather the data from the file and copy it all into the new one and therefore creating a backup but is there any easier way?
: : : : : : : : : :
: : : : : : : : : : Doing it the way i have explained is a lot of code and is very confusing. I mean, in windows, you could simply copy and paste the file and i was thinking along those lines.
: : : : : : : : : :
: : : : : : : : : : HELP
: : : : : : : : : :
: : : : : : : : : :
: : : : : : : : : :
: : : : : : : : : You could use the CopyFile() API function. Or you could open 2 TFileStream objects and call the CopyFrom() method. Here is the code for the stream variant:
: : : : : : : : :
: : : : : : : : :   Source := TFileStream.Create(SourceFileName, fmOpenRead);
: : : : : : : : :   Dest := TFileStream.Create(DestFileName, fmCreate);
: : : : : : : : :   Dest.CopyFrom(Source, Source.Size);
: : : : : : : : :   Dest.Free;
: : : : : : : : :   Source.Free;
: : : : : : : : : 

: : : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : : How does the copyfile() API function work
: : : : : : : :
: : : : : : : You provide 2 filenames, one for the source and one for the destination, and a boolean indicating if the destination should be overwritten. More info in the Windows API help.
: : : : : : :
: : : : : : can you do a bit of code like the other one. If its any help, one of the files is called "members.dat" and i want to copy it to removable storage.
: : : : : :
: : : : : The following code should copy (and overwrite existing) on the a:-drive:
: : : : :
: : : : :   CopyFile('members.dat', 'a:\members.dat', true);
: : : : : 

: : : : :
: : : :
: : : : is there any way to choose the place instead of hard coding it. Like choosing the place at run time
: : : :
: : : :
: : : Of course: using variables, or string properties from things like edit boxes, save and open dialogs, comboboxes, etc. You asked for an example, which you got based on the filename you gave. Remember that parameters don't necessarily be hard-coded.
: : :
: : you know if i put in an editbox, is there a way to bring up a little browse box in which the user can select a filepath? and then copy it
: :
: You could place a "Browse" button (as seen in many programs) next to the edit box. In the OnClick() you can place a code like this:
:
:   if SelectDirectory('Select a folder', 'C:\', s) then
:     EditBox1.Text := s;
: 

: With a little more coding, you can also use a TOpenDialog instead.
:
i dont understand what "s" means or is used for. Is selectdirectory a variable?


Report
Re: backup/restoration of files Posted by zibadian on 15 Feb 2006 at 4:35 AM
This message was edited by zibadian at 2006-2-15 4:36:7

:

:   if SelectDirectory('Select a folder', 'C:\', s) then
:     EditBox1.Text := s;



: With a little more coding, you can also use a TOpenDialog instead.
:
i dont understand what "s" means or is used for. Is selectdirectory a variable?

SelectDirectory() is a function, which is described in the help files. A variable can never have brackets "(" follow it. The variable s is necessasy because many properties cannot be used in a call to a variable procedure parameter.


Report
Re: backup/restoration of files Posted by sarkiemarkie on 15 Feb 2006 at 12:37 PM
This message was edited by sarkiemarkie at 2006-2-15 13:3:47

: This message was edited by zibadian at 2006-2-15 4:36:7

: :
:
:
: :   if SelectDirectory('Select a folder', 'C:\', s) then
: :     EditBox1.Text := s;
: 

:
:
: : With a little more coding, you can also use a TOpenDialog instead.
: :
: i dont understand what "s" means or is used for. Is selectdirectory a variable?
:
: SelectDirectory() is a function, which is described in the help files. A variable can never have brackets "(" follow it. The variable s is necessasy because many properties cannot be used in a call to a variable procedure parameter.
:
:
: i have set that all up now but im not sure how that would fit into my "COPYFILE" function:


CopyFile('Members.dat', 'Members.dat', false);
CopyFile('ViDvd.dat', 'ViDvd.dat', false);
CopyFile('Loans.dat', 'Loans.dat', false);
CopyFile('Prices.dat', 'Prices.dat', false);
CopyFile('Users.dat', 'Users.dat', false);






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.