File manipulation component

jbCFile.Pas

Version 1.01

Adapted to Delphi 1.0

Written by Jaro Benes

Copyright (c) 1991-98 by Jaro Benes. All rights reseved.

Please send comments to micrel@micrel.cz

Note:

If you have old DOS version jbFile, you can simply adapt to component, very much identifiers on name is stored.

Features:

Beta version of the very simply component for single copy file for generally using in Delphi 1.0.

Tested on Delphi programs.

Component TCopyFile

List of types, properties and events

Type declaration:

Declaration

TCopyOrMove=(swCCopy,swCMove);

TOverOrAppend=(swCAppend,swCOver);

TProgressOrSilent=(swCSilent,swCProgress);

TRequestOrSilent=(swCSilented,swCRequest);

TOverDialogs=(swCNone,swCDialogs);

TBackupOrThrow=(swCThrow,swCBackup);

TSetFileDate=(swCActual,swCSource,swCDest);

TNotifyEventProgress=procedure(Progress:Byte) of object;

TNotifyEventDialog=procedure(Const Msg:String) of object;

Main property:

Declaration

property Source:String;

Description:

Name of source file must be filled, exmpl: 'C:\MYFILE.TXT'.

Declaration

property Destination:String;

Description:

Name of destination must be full, without wildcards or without name of file, exmpl: 'C:\LIBURE\MYFILE.TXT'.

Execute property:

Declaration:

property CopyOrMove:TCopyOrMove;

Description:

Switch for copy file or move file. Default is swCCopy.

Declaration

property OverOrAppend:TOverOrAppend;

Description:

Switch for overwrite file or append to file. Default is swCAppend.

Declaration

property OverDialogs:TOverDialogs;

Description:

Switch if you wish own external dialog (here is implemented one only, you can add next). Default is swCNone.

Declaration

property ProgressOrSilent:TProgressOrSilent;

Description:

Switch if you wish attack progress bar etc. Default is swCSilent, for none.

Declaration

property RequestOrSilent:TRequestOrSilent;

Description:

Switch for using dialog, called is error occur on make new directory. Default is swCSilented.

Declaration

property BackupOrThrow:TBackupOrThrow;

Description:

Switch for do backup overwritten file or throw old file. Default is swCBackup.

Declaration

property DateOptions:TSetFileDate;

Description:

Switch for explicit set date and time of file. Set up times of source, destination or actual of copy file. Default is swCActual;

Events:

Declaration

property OnCopy: TNotifyEvent;

Description:

This event occur allways before copy segment of file.

Declaration

property OnProgress: TNotifyEventProgress;

Description:

This event occur if ProgressOrSilent is set to swCProgress and copying start, count of fin.

Declaration

property OnDialog: TNotifyEventDialog;

Description:

This event occur if RequestOrSilent is swCRequest and error occur (No disk space, Error on make directory)

Message strings

Const

ccMsg1='Error on make new directory';

ccMsg2='Empty file is deleted';

ccMsg3='Enought disk space for access';

Example:

Uses jbFile;

...

procedure TForm1.CopyFile1Progress(Progress: Byte);

begin

gauge1.Progress := Progress

end;

 

procedure TForm1.Button1Click(Sender: TObject);

var TC:TCopyFile;

begin

TC := TCopyFile.Create(Self);

Try

TC.Source:='c:\ooo.ooo';

TC.Destination:='a:\KOA\HAO\SOA\MOA\TIO\TIOUE.OOO';

TC.CopyOrMove := swCCopy;

TC.OverOrAppend := swCOver;

TC.ProgressOrSilent := swCProgress;

TC.OnProgress:=CopyFile1Progress;

If Not TC.CopyFile Then MessageDlg('Copy error',mtWarning,[mbOK],0);

Finally

TC.Free

End;

end;

...

{end of file, last updated 11.VI.1998}