[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

copy files in delphi

Posted on 1998-03-20
5
Medium Priority
?
312 Views
Last Modified: 2010-04-06
Hi,
I want my users be to be able to make a backup of their data. Hence I have to write some code to copy all files in lets say c:\data to c:\data\backup. How can I best do this?
Thanks
0
Comment
Question by:lizzzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:BoRiS
ID: 1360652
lizzzard try this function....

but remember to add LZexpand to your uses clause...

function CopyFile(SrcF,DestF : string) : boolean;
var
  SFile,
  DFile : integer;
  Res   : longint;
  Msg   : string;

begin
  SFile := FileOpen(SrcF,0);        { Open ReadOnly = 0, Write=1, Readwrite=2}
  DFile := FileCreate(DestF);
  Res := LZCopy(SFile,DFile);
  FileClose(SFile);
  FileClose(DFile);
  if Res < 0 then
  begin
    Msg := 'Unknown error';
    case Res of
      LZERROR_BADINHANDLE   : Msg := 'Invalid Source file handle';
      LZERROR_BADOUTHANDLE  : Msg := 'Invalid Destination file handle';
      LZERROR_BADVALUE      : Msg := 'Input parameter is out of range';
      LZERROR_GLOBALLOC     : Msg := 'Insufficient memory for the required buffers';
      LZERROR_GLOBLOCK      : Msg := 'Internal data structure handle invalid';
      LZERROR_READ          : Msg := 'Source file format is not valid';
      LZERROR_UNKNOWNALG    : Msg := 'The Source file was compressed with an unrecognized compression algorithm';
      LZERROR_WRITE         : Msg := 'There is insufficient space for the output file';
    end;
    MessageDlg(Msg,mtERROR,[mbOK],0);
    result := FALSE
  end else
    result := TRUE;
end;

Later
BoRiS
0
 
LVL 7

Expert Comment

by:ahalya
ID: 1360653
Why not do FindFirst, FindNext and call the WinAPI

copyFile(src, dst, FailIfExist) ?


0
 

Author Comment

by:lizzzard
ID: 1360654
I can't use LZExpand
0
 
LVL 3

Accepted Solution

by:
d4jaj1 earned 200 total points
ID: 1360655
There is a simple component caled uFileOps.  You can download it for Torry's site or post your email address here.  The component is free and allows you to do several file operations, including copying files very easily.  I use it my self and all I do to copy the files is write three lines of code -
Mask (eg *.db)
Loadfiles(false) - true adds teh full directory, false just teh files
Copyfiles - copies all of the files matching the mask above.

Pretty simple and comes with a help document.  If you need anymore answers from me, please post a comment here.  Good Luck!

Jay
0
 

Author Comment

by:lizzzard
ID: 1360656
Thanks d4jaj1 (what a name)

my email-adress is alexg@molyvos.net or give me the URL.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question