By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

ftp again

P: n/a
I've tried to download a file from a ftp server using it... but it doesn't
work....

does anyone has already used it?

Thank's.....

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet
As Integer) As Integer

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

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

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

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim INet, INetConn As Integer

Dim RC As Boolean

INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

INetConn = InternetConnect(INet, "ftp.mysite.com", 21, "username",
"password", 1, 0, 0)

RC = FtpGetFile(INetConn, "/web/fim.asp", "c:\fimdaniel.asp", True, 1, 1, 0)

If RC Then MessageBox.Show("Transfer succesfull!")

If Not RC Then MsgBox("Error")

InternetCloseHandle(INetConn)

InternetCloseHandle(INet)
--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Use NET component WebRequest instead

Crirus
"Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
news:eC*************@TK2MSFTNGP10.phx.gbl...
I've tried to download a file from a ftp server using it... but it doesn't
work....

does anyone has already used it?

Thank's.....

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer

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

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

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

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim INet, INetConn As Integer

Dim RC As Boolean

INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

INetConn = InternetConnect(INet, "ftp.mysite.com", 21, "username",
"password", 1, 0, 0)

RC = FtpGetFile(INetConn, "/web/fim.asp", "c:\fimdaniel.asp", True, 1, 1, 0)
If RC Then MessageBox.Show("Transfer succesfull!")

If Not RC Then MsgBox("Error")

InternetCloseHandle(INetConn)

InternetCloseHandle(INet)
--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630

Nov 20 '05 #2

P: n/a
can you give me a example?

thanks...

--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630
"Crirus" <Cr****@hotmail.com> escreveu na mensagem
news:OF**************@TK2MSFTNGP12.phx.gbl...
Use NET component WebRequest instead

Crirus
"Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
news:eC*************@TK2MSFTNGP10.phx.gbl...
I've tried to download a file from a ftp server using it... but it doesn't work....

does anyone has already used it?

Thank's.....

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet
As Integer) As Integer

Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer,

ByVal
sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As

Integer)
As Integer

Private Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName

As
String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal
sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer,
ByVal lContext As Integer) As Integer

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

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim INet, INetConn As Integer

Dim RC As Boolean

INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

INetConn = InternetConnect(INet, "ftp.mysite.com", 21, "username",
"password", 1, 0, 0)

RC = FtpGetFile(INetConn, "/web/fim.asp", "c:\fimdaniel.asp", True, 1,

1, 0)

If RC Then MessageBox.Show("Transfer succesfull!")

If Not RC Then MsgBox("Error")

InternetCloseHandle(INetConn)

InternetCloseHandle(INet)
--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630


Nov 20 '05 #3

P: n/a
imports SystemNet
.......
' Initialize the WebRequest.
Dim myRequest As WebRequest = WebRequest.Create("ftp://www.mysite.com")

' Return the response.
Dim myResponse As WebResponse = myRequest.GetResponse()

' Code to use the WebResponse goes here.
' Close the response to free resources.
myResponse.Close()
"Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
news:#D**************@TK2MSFTNGP09.phx.gbl...
can you give me a example?

thanks...

--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630
"Crirus" <Cr****@hotmail.com> escreveu na mensagem
news:OF**************@TK2MSFTNGP12.phx.gbl...
Use NET component WebRequest instead

Crirus
"Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
news:eC*************@TK2MSFTNGP10.phx.gbl...
I've tried to download a file from a ftp server using it... but it doesn't work....

does anyone has already used it?

Thank's.....

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal

HINet
As Integer) As Integer

Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer,

ByVal
sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As

Integer)
As Integer

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

Private Declare Function FtpGetFile Lib "wininet.dll" Alias

"FtpGetFileA" (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal
lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal
dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim INet, INetConn As Integer

Dim RC As Boolean

INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

INetConn = InternetConnect(INet, "ftp.mysite.com", 21, "username",
"password", 1, 0, 0)

RC = FtpGetFile(INetConn, "/web/fim.asp", "c:\fimdaniel.asp", True, 1,

1,
0)

If RC Then MessageBox.Show("Transfer succesfull!")

If Not RC Then MsgBox("Error")

InternetCloseHandle(INetConn)

InternetCloseHandle(INet)
--
_____________________________________________
Este é um grande mail de comunicação
Daniel Sélen Secches
ICQ 961630



Nov 20 '05 #4

P: n/a
there's a post entitled "ftp", oddly enough, that suggests how to use the
FtpWebRequest class...i recommend this interface over the suggestion of the
regular HttpWebRequest class.

hth,

steve
"Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
| can you give me a example?
|
| thanks...
|
| --
| _____________________________________________
| Este é um grande mail de comunicação
| Daniel Sélen Secches
| ICQ 961630
|
|
| "Crirus" <Cr****@hotmail.com> escreveu na mensagem
| news:OF**************@TK2MSFTNGP12.phx.gbl...
| > Use NET component WebRequest instead
| >
| > Crirus
| >
| >
| > "Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> wrote in message
| > news:eC*************@TK2MSFTNGP10.phx.gbl...
| > > I've tried to download a file from a ftp server using it... but it
| doesn't
| > > work....
| > >
| > > does anyone has already used it?
| > >
| > > Thank's.....
| > >
| > >
| > >
| > > Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal
| > HINet
| > > As Integer) As Integer
| > >
| > > Private Declare Function InternetOpen Lib "wininet.dll" Alias
| > > "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer,
| > ByVal
| > > sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As
| > Integer)
| > > As Integer
| > >
| > > Private Declare Function InternetConnect Lib "wininet.dll" Alias
| > > "InternetConnectA" (ByVal hInternetSession As Integer, ByVal
sServerName
| > As
| > > String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal
| > > sPassword As String, ByVal lService As Integer, ByVal lFlags As
Integer,
| > > ByVal lContext As Integer) As Integer
| > >
| > > Private Declare Function FtpGetFile Lib "wininet.dll" Alias
| "FtpGetFileA"
| > > (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal
| > > lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal
| > > dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal
| dwContext
| > > As Integer) As Boolean
| > >
| > > Private Declare Function FtpPutFile Lib "wininet.dll" Alias
| "FtpPutFileA"
| > > (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
| > > lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
| > > Integer) As Boolean
| > >
| > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
| > > System.EventArgs) Handles Button1.Click
| > >
| > > Dim INet, INetConn As Integer
| > >
| > > Dim RC As Boolean
| > >
| > > INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
| > >
| > > INetConn = InternetConnect(INet, "ftp.mysite.com", 21, "username",
| > > "password", 1, 0, 0)
| > >
| > > RC = FtpGetFile(INetConn, "/web/fim.asp", "c:\fimdaniel.asp", True, 1,
| 1,
| > 0)
| > >
| > > If RC Then MessageBox.Show("Transfer succesfull!")
| > >
| > > If Not RC Then MsgBox("Error")
| > >
| > > InternetCloseHandle(INetConn)
| > >
| > > InternetCloseHandle(INet)
| > >
| > >
| > > --
| > > _____________________________________________
| > > Este é um grande mail de comunicação
| > > Daniel Sélen Secches
| > > ICQ 961630
| > >
| > >
| >
| >
|
|
Nov 20 '05 #5

P: n/a
In article <eC*************@TK2MSFTNGP10.phx.gbl>, Daniel Sélen Secches wrote:
I've tried to download a file from a ftp server using it... but it doesn't
work....

does anyone has already used it?

Thank's.....


<snip>

This works for me...

Option Strict On
Option Explicit On

Imports System.Runtime.InteropServices

Module Module1
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInternet As IntPtr) As Boolean

Private Declare Auto Function InternetOpen Lib "wininet.dll" _
(ByVal lpszAgent As String, _
ByVal lAccessType As Integer, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Integer) As IntPtr

Private Declare Auto Function InternetConnect Lib "wininet.dll" _
(ByVal hInternet As IntPtr, _
ByVal lpszServerName As String, _
ByVal nServerPort As Short, _
ByVal lpszUserName As String, _
ByVal lpszPassword As String, _
ByVal dwService As Integer, _
ByVal dwFlags As Integer, _
ByVal dwContext As Integer) As IntPtr

Private Declare Auto Function FtpGetFile Lib "wininet.dll" _
(ByVal hConnect As IntPtr, _
ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, _
ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Integer, _
ByVal dwFlags As Integer, _
ByVal dwConext As Integer) As Boolean

Private Declare Auto Function FtpPutFile Lib "wininet.dll" _
(ByVal hConnect As IntPtr, _
ByVal lpszLocalFile As String, _
ByVal lpszNewRemoteFile As String, _
ByVal dwFlags As Integer, _
ByVal dwContext As Integer) As Boolean

Sub Main()
Dim hInet As IntPtr
Dim hConn As IntPtr

hInet = InternetOpen("my ftp", 1, vbNullString, vbNullString, 0)
Console.WriteLine("hInet = {0}", hInet)

hConn = InternetConnect(hInet, "yourserver", 21, "yourusername",
"yourpassword", 1, 0, 0)
Console.WriteLine("hConn = {0}", hConn)

Console.WriteLine("FtpGetFile Result = {0}", FtpGetFile(hConn,
"wininet.txt", "wininet.txt", True, 1, 1, 0))

InternetCloseHandle(hConn)
InternetCloseHandle(hInet)
End Sub

End Module
HTH
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #6

P: n/a
* "Daniel Sélen Secches" <daniel@cwdPONTOcomPONTObr> scripsit:
I've tried to download a file from a ftp server using it... but it doesn't
work....


Why do work others have already done?
VB.NET:

<http://www.freevbcode.com/ShowCode.Asp?ID=4655>
<http://www.allapi.net/downloads/NetFTP.zip>
<http://www.visualbuilder.com/article/viewarticle.asp?id=1234>
<http://www.abderaware.com/>

C#:

<http://www.csharphelp.com/archives/archive9.html>
<http://www.codeproject.com/csharp/FTPDriver1.asp>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.