Página 1 de 1
TFtp usage
Publicado: Jue Ene 22, 2015 2:05 pm
por mandantwin
Hello,
has anyone a sample how to use TFtp and read ASCII-files from the
Ftp:Server?
I didn't find any sample in the samples-directory.
Regards
Ingo
TFtp usage
Publicado: Jue Ene 22, 2015 4:40 pm
por joselalinf
Ingo,
> has anyone a sample how to use TFtp and read ASCII-files from the Ftp:Server?
This is from the TFTPFile component sources (I just commented out the code
to fire the events). Just use and abuse it to your needs.
METHOD Download() CLASS XFTPFile
LOCAL hFile, hRemote
LOCAL cBuffer := Space( ::nBuffer )
WITH OBJECT ::oFtp
:cUser := ::cUser
:cPassword := ::cPassword
:nTransferType := ::nTransferType
IF :Open()
IF :Connect( ::cServer )
IF ( hRemote := :OpenFile( ::cRemoteFile ) ) > 0
IF ( hFile := FCreate( ::cLocalFile ) ) > 0
//::OnStart( :GetFileSize( hRemote ) )
WHILE :ReadFile( hRemote, @cBuffer, ::nBuffer )
FWrite( hFile, cBuffer )
//::OnProgress( Len( cBuffer ) )
END
:CloseFile( hRemote )
FClose( hFile )
//::OnComplete()
ELSE
::OnError( FError(), "FCreate Error" )
ENDIF
ELSE
::OnError( :nLastError, :GetErrorDescription() )
ENDIF
ELSE
::OnError( :nLastError, :GetErrorDescription() )
ENDIF
:Close()
ELSE
::OnError( :nLastError, :GetErrorDescription() )
ENDIF
END
RETURN Nil
> I didn't find any sample in the samples-directory.
I will add one ASAP.
Regards,
José Lalín