Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: programatrix en 23 Diciembre 2005, 23:39 pm



Título: Problema función emulando inet
Publicado por: programatrix en 23 Diciembre 2005, 23:39 pm
Pues nada, ya conseguí mi módulo que emula a inet. Y baja super bien..., pero para subir ficheros me estoy dejando el pellejo y no consigo nada.
Haber si me podeis ayudar.
Esta es la órden en el formulario para subir:
Código:
Function subir(fichero As String)

Dim oFTP As New clsFTP
   
   
    oFTP.OpenConnection IP, usuario, pass, "/"

  [quote]  oFTP.UploadFile "C:\virus\a.zip", "a.zip"[/quote]

    oFTP.CloseConnection
  end function 
 
Y en un módulo de clase la función para subir
Código:
Public Function UploadFile(ByVal LocalFile As String, ByVal RemoteFile As String) As Boolean
    Dim bRet As Long
   
    bRet = FtpPutFile(hConnection, LocalFile, RemoteFile, FTP_TRANSFER_TYPE_BINARY, 0)
   
    If bRet = False Then
        App.LogEvent "Devx Sample failed to upload file " & LocalFile
        Call MsgBox("Error") 'puesto por mi  ;D
        Exit Function
    End If
End Function
Pues la cuestión es que no me lo sube nunca, se conecta superbien y me descarga ficheros anteriormente subidos pero no es capaz de subir ninguno, haber si me podeis hechar una mano.
La función de descarga es esta:
Código:
Public Function DownloadFile(FileName As String, Destination As String) As Boolean
    Dim sRemoteFile As String
    Dim sNewFile As String
    Dim sCurrentDir As String
   
   
    On Error GoTo out
   
    DownloadFile = False
   
    'Only if a valid connection...
    If hConnect Then
        ' Get the Current Internet directory
        sCurrentDir = GetFTPDirectory(hConnect)
       
        ' Setup the file name to retrieve and the destination
        sRemoteFile = sCurrentDir & FileName
        If Right$(Destination, 1) <> "\" Then
            Destination = Destination & sSlash
        End If
        sNewFile = Destination & FileName
         
        'make sure there is no file with the same name as specified
        Set oFSO = CreateObject("Scripting.FileSystemObject")
       
        If oFSO.FileExists(sNewFile) Then
          oFSO.DeleteFile sNewFile
        End If
       
        ' Download file
        If FtpGetFile(hConnect, sRemoteFile, sNewFile, False, FILE_ATTRIBUTE_ARCHIVE, _
            FTP_TRANSFER_TYPE_UNKNOWN, 0&) Then
            ' Success
            DownloadFile = True
            ErrLog "clsFTP.DownloadFile: Download Succeeded. Time:" & CStr(Now), 4
        Else
            ' Raise an error
            ErrLog "clsFTP.DownloadFile: Download Failed. " & Err.Number & ":" & _
                                                            Err.Description, 1
        End If
    End If
    Exit Function
out:
    ErrLog "clsFTP.DownloadFile method failed. Error - " & Err.Description, 1
End Function
Saludos y ojala me podais ayudar  ::)


Título: Re: Problema función emulando inet
Publicado por: Kizar en 24 Diciembre 2005, 00:30 am
Dim bRet As Long

If bRet = False Then
        App.LogEvent "Devx Sample failed to upload file " & LocalFile
        Call MsgBox("Error") 'puesto por mi  ;D
        Exit Function
End If

si bRet no esta declarado como bolean, no va devolver true o false.

Eso creo yo, weno de toas maneras podias acer k un code espere a k se aya subido el archivo o algo.

Salu2


Título: Re: Problema función emulando inet
Publicado por: programatrix en 24 Diciembre 2005, 11:22 am
No creo que esté hay el problema. Lo que pasa es que está función devuelbe false:
Citar
FtpPutFile(hConnection, LocalFile, RemoteFile, FTP_TRANSFER_TYPE_BINARY, 0)
Por eso se compara y vale as long.
Voy haber si cogiendo código de la descarga puedo arreglarlo  ::)