 |
| Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 8th, 2003, 11:49 AM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
FTP from inside VB.NET Program
I would like to ftp a file from inside a vb.net program. I've looked on the web but have seen mostly reccommendations for third party components. I've sent e-mails from vb.net (in an asp.net applicaitons) so I figure there should be something similar (an ftp object for istance) that is already part of vb.net.
Does anyone have any suggestions/code.
Neil
|
|

July 10th, 2003, 08:49 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
We had the same problem some months ago, but we chose to buy a component instead (the dart ftp.net component). Saved us a lot of time and frustration. Can handle asynchronous and synchronous ftp transfer. Didn't found some code to use and the lack of time and knowledge made us buy it.
|
|

July 11th, 2003, 08:37 AM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello,
Here is a link to a complete guide on how to implement FTP within VB.NET. It's a tad complicated...but worth the effort.
cheers!
|
|

July 11th, 2003, 08:38 AM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

July 11th, 2003, 05:23 PM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I thought someone might be interested in a REALLY simple solution I got this one off another message board:
It got me going in minutes. I am curious as to why complicated solutions seem to be more popular than simpleones.
Neil
__________________________________________________ __________
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
...
Dim INet, INetConn As integer
Dim RC As Boolean
INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, "www.yoursite.com";, 0, "yourlogin", "yourpassword", 1, 0, 0)
RC = FtpGetFile(INetConn, "/folder/subfolder/name.ext", "c:\tmp\downloaded.ext", true, 1, 0, 0)
If RC Then MessageBox.show( "Transfer succesfull!")
InternetCloseHandle INetConn
InternetCloseHandle INet
|
|

July 27th, 2003, 11:09 PM
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Just wondering if anyone has managed to get the really simple solution that fig000 posted working. I too am trying to implement ftp inside a VB.Net program, and had found those lines of code on the web too.
The InternetOpen and InternetConnect calls seem to be working (ie it doesn't return 0), but the FtpGetFile always returns False - its not getting the file. I have no idea why. Anyone else had any luck with this?
|
|

August 21st, 2003, 03:37 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello,
you could also try several free ftp libraries found at www.codeproject.com. You could also try Rebex FTP.net component - it comes with a lot of samples (both vb.net and c#). It even includes WinForm ftp client similar to Windows Commander (aka Total Commander) with complete vb.net source code...
http://www.rebex.net/ftp.net/
|
|

October 14th, 2003, 09:55 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The above method for FTPing files works like a charm. I created a nice little program that ftps to all my machines and pulls some files. I agree you should not use a brick to kill a fly if you don't need to.
To answer the problem about not getting the ftp file.. you should try using the command line ftp program in windows to debug.. try to replicate the same steps as you are doing in your program. Then at least can narrow down your problem.
|
|

October 27th, 2003, 08:52 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok guys, I am also trying to use the code fig000 is using and i have the same problem as jazzart, did any one solve this, the ftp file isnot transferred for some reason ....
|
|

October 27th, 2003, 03:55 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can you send a code snippet.
|
|
 |