Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 8th, 2003, 11:49 AM
Registered User
 
Join Date: Jul 2003
Location: Knoxville, TN, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old July 10th, 2003, 08:49 AM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #3 (permalink)  
Old July 11th, 2003, 08:37 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TDot Send a message via Yahoo to TDot
Default

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!

Reply With Quote
  #4 (permalink)  
Old July 11th, 2003, 08:38 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TDot Send a message via Yahoo to TDot
Default

Sorry, forgot to post the link (duh)...

http://support.microsoft.com/default...en-us%3B812404

Reply With Quote
  #5 (permalink)  
Old July 11th, 2003, 05:23 PM
Registered User
 
Join Date: Jul 2003
Location: Knoxville, TN, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #6 (permalink)  
Old July 27th, 2003, 11:09 PM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?



Reply With Quote
  #7 (permalink)  
Old August 21st, 2003, 03:37 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/

Reply With Quote
  #8 (permalink)  
Old October 14th, 2003, 09:55 PM
Registered User
 
Join Date: Oct 2003
Location: San Mateo, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #9 (permalink)  
Old October 27th, 2003, 07:52 AM
Registered User
 
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ....

Reply With Quote
  #10 (permalink)  
Old October 27th, 2003, 02:55 PM
Registered User
 
Join Date: Oct 2003
Location: San Mateo, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you send a code snippet.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uploading Text File to FTP server in vb.net KiruShan .NET Framework 2.0 4 July 29th, 2014 02:02 AM
loop through tables inside .mdb file using VB.NET remya1000 General .NET 3 September 24th, 2007 12:45 PM
Start a program inside another program Silje Classic ASP Professional 1 November 16th, 2004 01:08 AM
Running FTP within VB .NET Application ocarroll General .NET 7 September 28th, 2004 04:25 PM



All times are GMT -4. The time now is 09:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.