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
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
TFtp usage
-
- Mensajes: 11
- Registrado: Dom Jul 04, 2010 7:12 am
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
TFtp usage
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
> 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