Sto facendo un applicazione per uno scanphone con windows mobile che deve collegarsi tramite GPRS e inviare/ricevere file tramite FTP.
Per i trasferimenti FTP uso i metodi a disposizione della wininet.dll
(http://msdn.microsoft.com/en-us/libr...sktop/aa385483(v=vs.85).aspx)
e funzionano FTPget, FTPput ecc..
Non riesco ad utilizzare la funzione FTPcommand, che mi sarebbe molto utile per fare un LS dei file nel server FTP. In realtà questo metodo non mi funziona con nessun tipo di comando che voglio inviare: la funzione mi restituisce sempre False.
Dove potrebbe essere l'errore?
Allego la dichiarazione e il richiamo del metodo:
codice:
Public Declare Function FtpCommand Lib "wininet.dll" Alias "FtpCommandA" _
(ByVal hFtpSession As Long, ByVal fExpectedReponse As Boolean, _
ByVal dwFlags As Long, ByVal lpszCommand As String, _
ByVal dwContext As Long, ByVal phFtpCommand As Long) As Boolean
Private Sub connessione_ftp_transfer()
...
Dim RC As Boolean
INet = InternetOpen("ftp", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, server_ftp, porta_ftp, user_server_ftp, password_server_ftp, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0)
If INetConn <> 0 Then
connessione_eseguita = True
Try
Dim hResponse
Dim command As String = "PASV"
Dim hOutConn&
RC = FtpCommand(INetConn, True, FTP_TRANSFER_TYPE_ASCII, command, 0, hOutConn)
If RC = True Then
MessageBox.Show(hOutConn.ToString)
Else
MessageBox.Show("Niente PASV")
End If
command = "LS"
Dim retv As Long
RC = FtpCommand(INetConn, True, 2, command, 0, retv)
If RC = True Then
MessageBox.Show(hOutConn.ToString)
Else
MessageBox.Show("Niente LS")
End If
command = "LIST" & VbCrLf
RC = FtpCommand(INetConn, True, FTP_TRANSFER_TYPE_ASCII, command, 0, retv)
If RC = True Then
MessageBox.Show(hOutConn.ToString)
Else
MessageBox.Show("Niente LIST")
End If
command = "QUIT" & vbCrLf
RC = FtpCommand(INetConn, True, FTP_TRANSFER_TYPE_UNKNOWN, command, 0, hOutConn)
If RC = True Then
MessageBox.Show(hOutConn.ToString)
Else
MessageBox.Show("Niente QUIT")
End If
...
End Sub
Come vedete ho fatto varie prove con diversi comandi e dando parametri diversi al metodo, ma restituisce sempre False