<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloConnection > TApolloConnection Methods > FileSend |
Declaration
function FileSend( sDatabaseName, srcFile, desFile: String ): Integer;
Description
Transfers a file (any file) from the client to the remote server. The file will be copied from the local (client) directory and file name specified in the srcFile parameter. The destination file name (desFile) will be copied to the remote server directory associated with the sDatabaseName parameter. Use the FileExists method to insure that no remote file of this name already exists. The return value is the number of bytes transferred to the server.
Parameters
sDatabaseName is the remote database name where the destination file will be sent to.
srcFile is the name of the source file to be copied from the local machine. This parameter may include the drive and path information.
desFile is the name of the destination file to be created on the remote server.
Returns
The number of bytes sent are returned as an Integer. This value can be compared to the result of FileLength to verify a successful transfer.
Delphi Example
procedure TForm1.Button1Click(Sender: TObject);
var
SearchRec: TSearchRec;
iLen : Integer;
begin
ApolloConnection1.Active := True;
with ApolloConnection1 do
begin
// If this file already exists on server, prompt user for confirmation
if FileExists( 'SAMPLEDATA', 'MYTEST.DBF' ) then
if MessageDlg( 'Overwrite existing file on server?', mtConfirmation, mbOkCancel, 0 ) = mrCancel then
Exit;
// Verify source file exists, and get length of file
if SysUtils.FindFirst( 'C:\Apollo\MyTest.dbf', faArchive, SearchRec ) = 0 then
begin
// Send file to server, get number of bytes transferred...
iLen := FileSend( 'SAMPLEDATA', 'C:\Apollo\MyTest.dbf', 'MYTEST.DBF' );
// ... and compare them to original file length
if iLen <> SearchRec.Size then
ShowMessage( 'Error sending file!' );
end;
SysUtils.FindClose( SearchRec );
end;
end;
See Also
FileReceive, FileExists, DatabaseName