Creare una cartella sul area FTP

Moderator: Enrico Maria Giordano

Post Reply
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Creare una cartella sul area FTP

Post by Romeo »

Ciao,
mi pare di avere visto da qualche parte qualche indicazione di come creare una cartella su un'area FTP.

Non mi pare che con la classe TFTP o TFTPFile si riesca a farlo, eppure mi pareva di avere visto qualcosa in giro.

Qualche indicazione utile ?

FWH 2.4

Grazie
Romeo/Zingoni
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Creare una cartella sul area FTP

Post by Enrico Maria Giordano »

Code: Select all

STATIC FUNCTION FTPCREATEDIR( cFtp, cPer, cUsr, cPsw, cDir )

    LOCAL hInternet, hConnect

    LOCAL lOk

    hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
    hConnect = INTERNETCONNECT( hInternet, cFtp, INTERNET_INVALID_PORT_NUMBER, cUsr, cPsw, INTERNET_SERVICE_FTP, 0, 0 )

    lOk = FTPCREATEDIRECTORY( hConnect, cPer + "/" + cDir )

    INTERNETCLOSEHANDLE( hConnect )
    INTERNETCLOSEHANDLE( hInternet )

    RETURN lOk

Code: Select all

#pragma BEGINDUMP

#include "windows.h"
#include "wininet.h"
#include "hbapi.h"


HB_FUNC( INTERNETOPEN )
{
    hb_retnl( ( LONG ) InternetOpen( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ), hb_parnl( 5 ) ) );
}


HB_FUNC( INTERNETCLOSEHANDLE )
{
    hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}


HB_FUNC( INTERNETCONNECT )
{
    hb_retnl( ( LONG ) InternetConnect( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), ( INTERNET_PORT ) hb_parnl( 3 ), hb_parc( 4 ), hb_parc( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) ) );
}


HB_FUNC( FTPGETFILE )
{
    hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );
}


HB_FUNC( FTPPUTFILE )
{
    hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}


HB_FUNC( FTPDELETEFILE )
{
    hb_retl( FtpDeleteFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}


HB_FUNC( FTPCREATEDIRECTORY )
{
    hb_retl( FtpCreateDirectory( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}


HB_FUNC( FTPREMOVEDIRECTORY )
{
    hb_retl( FtpRemoveDirectory( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}


HB_FUNC( FTPFINDFIRSTFILE )
{
    hb_retnl( ( LONG ) FtpFindFirstFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), ( WIN32_FIND_DATA * ) hb_parc( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}


HB_FUNC( INTERNETFINDNEXTFILE )
{
    hb_retl( InternetFindNextFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

#pragma ENDDUMP
EMG
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Post by Romeo »

Miiiiii,
la prima parte ok,
come faccio ad usare la seconda parte ?
Compilata normalmente mi risponde picche !

Grazie
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

In che senso? Metti semplicemente tutto dentro a un PRG e compila. Se ti dà degli errori è il caso di farmeli sapere, non credi? :-)

EMG
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Post by Romeo »

Ciao EMG, compilando con FWH24 un minimale esempio.prg mi da i seg.errori:

Error: Unresolved external 'InternetOpenA'
Error: Unresolved external 'InternetCloseHandle'
Error: Unresolved external 'InternetConnectA'
Error: Unresolved external 'FtpGetFileA'
Error: Unresolved external 'FtpPutFileA'
Error: Unresolved external 'FtpDeleteFileA'
Error: Unresolved external 'FtpCreateDirectoryA'
Error: Unresolved external 'FtpRemoveDirectoryA'
Error: Unresolved external 'FtpFindFirstFileA'
Error: Unresolved external 'InternetFindNextFileA'

Grazie

Romeo
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Devi includere la libreria wininet.lib che trovi nel tuo compilatore C.

EMG
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Post by Romeo »

Ovviamente...funziona
Grazie 1000
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Post by Romeo »

Ok,
Chiaramente tutto funziona.
Grazie 1000
Post Reply