BAIXAR ARQUIVO VIA FTP

USUARIO.EXCLUIDOS 08/09/2007 12:37:33
#234741
e ai galera estou com um problema estou conectando a um ftp com o componente inet e estou fazendo o seguinte comando
"get configuracao.txt c:\configuração.txt" e o arquivo nao esta sendo baixado nao sei o que pode ser , ja estou dentro do diretorio onde se encontra o arquivo mas mesmo assim nao esta sendo baixado .

alguem pode me ajudar nessa ?

valew galera
USUARIO.EXCLUIDOS 08/09/2007 13:23:22
#234749
e ai galera alguem pode me ajudar ?
USUARIO.EXCLUIDOS 08/09/2007 22:58:08
#234791
Resposta escolhida
Pessoalmente não gosto de utilizar o INET para FTP.
Aconselho-o a utilizar API... Aqui vai:

Coloque num módulo o seguinte código:
'DECLARAÇÕES NECESSÁRIAS PARA A LIGAÇÃO FTP
Public lngINet As Long
Public lngINetConn As Long
Public blnRC As Boolean
Public pData As WIN32_FIND_DATA
Public lngHINet As Long

Public Const MAX_PATH As Integer = 260

Public Type FileTime
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Public Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FileTime
ftLastAccessTime As FileTime
ftLastWriteTime As FileTime
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long

Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, _
ByVal nServerPort As Integer, ByVal sUsername As String, _
ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean

Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer

Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _
(ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _
lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, _
ByVal dwContent As Long) As Long

Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" _
(ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long


Utilize desta forma num form:
Private Function ligaFTP(ByVal urlFTP As String)
lngINet = InternetOpen("Ligar", 1, vbNullString, vbNullString, 0)
lngINetConn = InternetConnect(lngINet, urlFTP, 0, "login", "password", 1, 0, 0)

If not lngINetConn = 0 Then
blnRC = FtpGetFile(lngINetConn, "/caminho para o arquivo", "caminho para gravar arquivo", 0, 0, 1, 0) 'mude o 1 para 2 se o arquivo for binário
End If

InternetCloseHandle lngINetConn
InternetCloseHandle lngINet

end function


Espero ter ajudado.
USUARIO.EXCLUIDOS 09/09/2007 12:54:09
#234812
valew miguel peguei seu exmplo e criei uma classe que ficou show valew mesmo cara
Tópico encerrado , respostas não são mais permitidas