FTP ???

FTP ???

Postby Mayor_Valenzuela » Tue Jun 07, 2011 7:08 pm

Hola nuevamente...

Manejo muy bien el tema del FTP, puedo subir y bajar archivos pero que pasa cuando los necesito bajar y eliminar???

Si alguien tiene una idea... Uso


DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpGetFileA" LIB "wininet.dll"

DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpPutFileA" LIB "wininet.dll"

Para descargar subir un archivo y ahora necito eliminar el que descarge...
Mario Valenzuela M.
Santiago, Chile.
User avatar
Mayor_Valenzuela
 
Posts: 62
Joined: Tue Jul 08, 2008 4:27 pm
Location: Santiago, Chile

Re: FTP ???

Postby Manuel Valdenebro » Tue Jun 07, 2011 7:48 pm

Comprueba si te funciona esto:

DLL32 FUNCTION FtpDeleteFile( hFTP AS LONG, cFileName AS LPSTR ) AS BOOL PASCAL ;
FROM "FtpDeleteFileA" LIB hWinINet
Un saludo

Manuel
User avatar
Manuel Valdenebro
 
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re: FTP ???

Postby Mayor_Valenzuela » Wed Jun 08, 2011 12:45 pm

Muchisimas gracias... la verdad que busque mucho sobre estas funcionesno teniendo existo... muy agradecido...
Mario Valenzuela M.
Santiago, Chile.
User avatar
Mayor_Valenzuela
 
Posts: 62
Joined: Tue Jul 08, 2008 4:27 pm
Location: Santiago, Chile

Re: FTP ???

Postby MarioG » Wed Jun 15, 2011 12:41 pm

Hola;
Estoy interesado en usar estas funciones, y mas presisamente en esta:
DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpGetFileA" LIB "wininet.dll"

Me podrían decir el valor de los siguientes parámetros, o como los obtengo?
cRemoteFile: debe ser la dirección completa del FTP?
cNewFile: se puede incluir el camino de la carpeta destino?
hConnect: si me conecto con TFtpFile(), obtengo tal valor de la clase?
nFaillExists: ?
nFlagsAndAttribs: ?
nFlags: ?
nContext: ?

muchas gracias
Resistencia - "Ciudad de las Esculturas"
Chaco - Argentina
User avatar
MarioG
 
Posts: 1380
Joined: Fri Oct 14, 2005 1:28 pm
Location: Resistencia - Chaco - AR

Re: FTP ???

Postby Mayor_Valenzuela » Thu Jun 30, 2011 12:57 pm

Este ejemplo lo puedes usar para entender como funciona... debe crear o tener una cuenta FTP para poder conectarte...

Code: Select all  Expand view

#include "FiveWin.ch"
#include "TsButton.ch"
#define FILE_ATTRIBUTE_READONLY 1
#define FILE_ATTRIBUTE_HIDDEN 2
#define FILE_ATTRIBUTE_SYSTEM 4
#define FILE_ATTRIBUTE_DIRECTORY 16
#define FILE_ATTRIBUTE_ARCHIVE 32
#define FILE_ATTRIBUTE_NORMAL 128
#define FILE_ATTRIBUTE_TEMPORARY 256
#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS
#define INTERNET_INVALID_PORT_NUMBER    0       // use the protocol-specific default
#define INTERNET_DEFAULT_FTP_PORT       21      // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT    70      //    "     " gopher "
#define INTERNET_DEFAULT_HTTP_PORT      80      //    "     " HTTP   "
#define INTERNET_DEFAULT_HTTPS_PORT     443     //    "     " HTTPS  "
#define INTERNET_DEFAULT_SOCKS_PORT     1080    // default for SOCKS firewall servers.
#define INTERNET_SERVICE_FTP     1
#define INTERNET_SERVICE_GOPHER  2
#define INTERNET_SERVICE_HTTP    3
#define INTERNET_FLAG_TRANSFER_ASCII  1
#define INTERNET_FLAG_TRANSFER_BINARY 2
Static oWnd
Static hBorland, User, hParaBNt
*..............................................................................................................................*
Function Main()
Local oDlg, oBar, oBmp, oIco, lOk, Local1:=GetWinDir(), oFont[1], FileName, oItem, oBsh, oTxt
Public Ubica:=CurDrive()+":\"+CurDir()
Public nClr:=aRGB( GetSysColor(15) ), CLR_SYSTEM

CLR_SYSTEM := RGB( nClr[1],nClr[2],nClr[3] )
hBorland:=LoadLibrary( "
.\System\bwcc32.dll" )
Set Date British
Set Century On
Set _3DLOOK On

DEFINE FONT oFont[1] NAME "
Arial" WEIGHT 12

DEFINE DIALOG oDlg RESOURCE "
DIALOG_MAIN" ICON oIco COLOR CLR_BLACK, CLR_WHITE BRUSH oBsh

 REDEFINE SBUTTON ID 101 NAME "
RUN2" TEXT POSITION ON_BOTTOM OF oDlg ACTION ( GetFtp( oDlg ) ) BORDER CANCEL
 REDEFINE SAY oTxt ID 102 OF oDlg

ACTIVATE DIALOG oDlg CENTERED;
         VALID ( If( !GetKeyState( VK_ESCAPE ),  .T.,  .F. ) )

Return ( Nil )
*..............................................................................................................................*
Static Function GetFtp(oDlg)
Local oInternet, usuario:="
administrador@banks.com", password:="xxxxxx"  // estas se reemplazan con tu usuario y password
Local oFtp, lExito, False:=.F., True:=.T.
Local cLocalFile:="
C:\Link\Mproduct.zip", cRemoteFile:="/LTO/mproduct.zip"

 oInternet := TInternet():New()
 oFTP      := TFTP():New( "
167.119.250.194", oInternet, usuario, password )
 hLib = LOADLIBRARY( "
wininet.dll" )
 hInternet = INETOPEN( "
Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
 hConnect = INETCONNECT( hInternet, "
167.119.250.194",  21, usuario, password,1, 0, 0 )
 IF hConnect = 0
   MsgAlert("
Fallo la conección con el Servidor!" + chr(13)+"Intente nuevamente.")
   FREELIBRARY( hLib )
   INETCLOSEHANDLE( hConnect )
   INETCLOSEHANDLE( hInternet )
   FREELIBRARY( hLib )
   Return ( Nil )
 Else
     MsgRun( "
Descargando archivo local MALL PLAZA, favor esperar.","Conectando")
   lExito := FTPGETFILE( hConnect, cRemoteFile, cLocalFile, 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0)
   If !lExito
     MsgAlert( "
No se pudo realizar la descarga desde el servidor.", "Error!")
     FREELIBRARY( hLib )
     INETCLOSEHANDLE( hConnect )
     INETCLOSEHANDLE( hInternet )
     FREELIBRARY( hLib )
         MsgRun("
")
     Else
         aFiles := hb_GetFilesInZip(cLocalFile)
         hb_unzipfile(cLocalFile,,.T.,,"
C:\", aFiles, NIL)
         While .T.
           If ( CopyFile("
c:\Link\Fab\LTO\Mproduct.dat", "c:\Ventas\Bases\Mproduct.dat") = .F. )
               If ( MsgYesNo("
Es necesario que salga del sistema de ventas para realizar este proceso. Desea reintentar?", "Error") )
                     Loop
                 Else
                        Exit
               EndIf
             Else
                 Exit
           EndIf
         End While
   EndIf
     oDlg:End()
     MsgRun("
")
  EndIf

Return ( Nil )
*...............................................................................................................................*
DLL32 FUNCTION INETOPEN( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags AS DWORD ) AS LONG;
PASCAL FROM "
InternetOpenA" LIB "wininet.dll"

DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
PASCAL FROM "
InternetCloseHandle" LIB "wininet.dll"

DLL32 FUNCTION INETCONNECT( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG;
PASCAL FROM "
InternetConnectA" LIB "wininet.dll"

DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "
FtpGetFileA" LIB "wininet.dll"

DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "
FtpPutFileA" LIB "wininet.dll"

DLL FUNCTION COPYFILE( cExistingFileName AS LPSTR, cNewFileName AS LPSTR, lFailIfExists AS LONG ) AS BOOL;
    PASCAL FROM "
CopyFileA" LIB "kernel32.dll"
*...............................................................................................................................*


Mario Valenzuela M.
Santiago, Chile.
User avatar
Mayor_Valenzuela
 
Posts: 62
Joined: Tue Jul 08, 2008 4:27 pm
Location: Santiago, Chile

Re: FTP ???

Postby jbrita » Thu Jun 30, 2011 1:17 pm

Mario,
tienes un correo para contactarte

Saludos
jbrita
 
Posts: 486
Joined: Mon Jan 16, 2006 3:42 pm

Re: FTP ???

Postby QAZWSX2K » Thu Jun 30, 2011 3:05 pm

sobre FTP les cuento que todas esas funciones, generan un atchivo log, de nombre ftp.log, ftp0.log, ftp1.log...ftp2222.log cada vez que se ejecutan y si ven ese archivo log aparece hasta la clave en cristiano, cosa entonces que cualquier puede despues manualmente a nuestro ftp y por supuesto hacer y deshacer por ahi, entonces mi preguntas es..

¿existe alguna variable dentro de esta clase para que no genere el archivo log?
Software especializado para oficinas contables con grandes volumenes de Informacion
Impresion de todos los formularios del Seniat, Dian

alex_patino74@hotmail.com
whatsapp 57+3214777217
User avatar
QAZWSX2K
 
Posts: 363
Joined: Tue Oct 25, 2005 7:06 pm
Location: Bogota - Caracas

Re: FTP ???

Postby MarioG » Thu Jun 30, 2011 3:10 pm

Mayor;
muchas gracias, lo probaré

JB mi correo es: mario.r.gonzalez(a)gmail.com
Resistencia - "Ciudad de las Esculturas"
Chaco - Argentina
User avatar
MarioG
 
Posts: 1380
Joined: Fri Oct 14, 2005 1:28 pm
Location: Resistencia - Chaco - AR

Re: FTP ???

Postby Mayor_Valenzuela » Mon Jul 04, 2011 8:58 pm

Mi correo...

mayor_valenzuela@hotmail.com

Espero haber aportado en algo, y ante cualquier duda n duden en contactarme por correo..
Mario Valenzuela M.
Santiago, Chile.
User avatar
Mayor_Valenzuela
 
Posts: 62
Joined: Tue Jul 08, 2008 4:27 pm
Location: Santiago, Chile


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests