473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ftp again

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
6 1809
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
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
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
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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Phil Powell | last post by:
I am having this problem: My PHP script will set a cookie, it's there in my /Cookies folder. I delete the cookie (I have to for testing purposes, the PHP script I run behaves according to this...
5
by: Bruce | last post by:
I have a number of forms that do significant work based on variables POSTed from the form. What is the common method of detecting and preventing this work from being done when the form is POSTed as...
1
by: Jiten | last post by:
Hi Cor I spoke with u previously about this problem i had and u gave me some code that helped me. That code worked fine but i have now encountered another issuee that im hoping u may know how to...
8
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting...
17
by: Gabriel Mejía | last post by:
Services or applications using ActiveX Data Objects (ADO) 2.0 or greater may intermittently return empty recordsets on queries that should be returning valid results. At the time the problem...
3
by: penny336 | last post by:
dear all, i am using vc++ 6.0 sp5 i have a class called Address,it allocated some memory space for streetname and city i first define it as Address add = new Address("Madrian","UK"); ......
11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
6
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
5
by: Mike TI | last post by:
March 24, 2006 Hi all I am new to VB.NET and am using VB.NET 2005. I have an MDI form with a Split Container Control. On demand I am adding and removing User Controls on Panel 2. I am using...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.