<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloConnection > TApolloConnection Methods > FileExists |
Declaration
function FileExists( sDatabaseName, sFileName: String ): Boolean;
Description
Looks for the specified file in the specified database on the remote server.
Parameters
sDatabaseName is the name of the database to look for the file in.
sFileName is the name of the file to look for.
Returns
Returns True if specified file exists on the remote server, False if not.
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
FileLength, DatabaseName