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
  #11 (permalink)  
Old October 29th, 2003, 11:36 AM
Authorized User
 
Join Date: Oct 2003
Location: Bohemia, NY, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I took the code fig000 posted and put it right into an application with no problems. I didn't have to change much if anything at all if I remember correctly.

Good luck all

Thanks,
Risu
Reply With Quote
  #12 (permalink)  
Old October 30th, 2003, 11:15 AM
Registered User
 
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In regards to fig000's post regarding the simple FTP solution. I too am trying to implement such a solution in VB.NET but the FTPGetFile is not working for me either. Always returns false and doesn't get the file. We've had problems running these same steps through a .cmd script when running on an XP box (get a 550 disconnect error) but it works fine on an NT box, which I why I'm attempting to do this in VB.NET. I think there maybe something wrong with the FTP client on XP. Just wondering if those of you who have had success with this code are running on NT boxes? Has anyone got it working on an XP box? Thanks.


Reply With Quote
  #13 (permalink)  
Old October 30th, 2003, 12:26 PM
Authorized User
 
Join Date: Oct 2003
Location: Bohemia, NY, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

grover4444,

Very good point, when I ran it it was on a 2k box not an XP box. Unfortunately I do not have an XP box to try it out on.
Hope this little bit helps.

Thanks, Risu
Reply With Quote
  #14 (permalink)  
Old November 2nd, 2003, 01:37 PM
Registered User
 
Join Date: Nov 2003
Location: Tel-Aviv, , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Too all Free-FTP-seekers!

this link might just be what you are looking for.

http://www.aspsimply.com/VBNet/DotNetFTP.aspx



Rastafary!


Reply With Quote
  #15 (permalink)  
Old November 3rd, 2003, 07:51 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Buying a component is an Expensive Option.

The internet trasfer control does not work for FTP and the code using the WinAPI calls only works on some servers. I wish I knew why.
Reply With Quote
  #16 (permalink)  
Old November 3rd, 2003, 11:09 PM
Registered User
 
Join Date: Oct 2003
Location: San Mateo, CA, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got it to work fine with XP. I used pretty much the code that was provided above by fig000.

Private Function GetFile(ByVal machine As String) As String
        ' Open an FTP connection to the machine and get myfile.txt

        ' Connect (for now) to user1 only
        Dim INet, INetConn As Integer
        Dim RC As Boolean
        INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
        INetConn = InternetConnect(INet, machine, 0, "user1", "password", 1, 0, 0)
        RC = FtpGetFile(INetConn, "~/myfile.txt", "c:\\temp\\myfile." & machine & ".txt", True, 1, 1, 0)
        If RC Then MessageBox.Show("Transfer succesfull!")
        InternetCloseHandle(INetConn)
        InternetCloseHandle(INet)
    End Function


Quote:
quote:Originally posted by grover4444
 In regards to fig000's post regarding the simple FTP solution.  I too am trying to implement such a solution in VB.NET but the FTPGetFile is not working for me either.  Always returns false and doesn't get the file.  We've had problems running these same steps through a .cmd script when running on an XP box (get a 550 disconnect error) but it works fine on an NT box, which I why I'm attempting to do this in VB.NET.  I think there maybe something wrong with the FTP client on XP. Just wondering if those of you who have had success with this code are running on NT boxes?  Has anyone got it working on an XP box? Thanks.


Reply With Quote
  #17 (permalink)  
Old November 18th, 2003, 11:52 AM
Authorized User
 
Join Date: Oct 2003
Location: Bohemia, NY, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Along the lines of this, I was wondering if there is a way to either delete the file on the FTP server after you get it or to rename it. If anyone has links to any documentation of wininet that may list it's functions would also help to see whats available.

Thanks,
Risu
Reply With Quote
  #18 (permalink)  
Old January 9th, 2004, 05:43 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

FYI...

I spent ALL day today trying to find a way to simply FTP a file to my ftp site using VB.NET.


I heard about fig000's solution on another site, but I couldn't find the actual code... then I finally stumbled on this thread.

At first, I had the same problem as everyone else... the GetFile would always return False...

...then I tried the dll solution that DesertPalm linked to. Actually, I had already tried that solution earlier in the day, and I still had a project open that referenced that dll, so I figured that I'd give it another shot. Each time, the Upload_Download Sub would always return "False", just like the GetFile function in the API solution... Well, fortunately, the DLL function includes the ability to create a connection log file... so after a number of trial-and-error attempts and log checks, I found that my problem was simply that I was not typing the "RemoteFile" path correctly.

Once I figured out how to write the RemoteFile path, both the DLL solution and the API solution worked just fine.

The problem is... the defualt folder that you are linked to when you log in to an FTP server is different from server to server. And in the case of my server, it already adds the trailing "/" to the defualt folder. So all I had to do was change my RemoteFile from "/MyFiles/myfile.txt" to "MyFiles/myfile.txt" and it worked.

So try messing around with the path you're using in the RemoteFile string, and you may get it to work.


WATYF
Reply With Quote
  #19 (permalink)  
Old February 12th, 2004, 03:43 PM
Authorized User
 
Join Date: Dec 2003
Location: holtsville, ny, USA.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does anyone know whether a success return value from a call to FTPPutFile means that the file was created successfully with the exact # of bytes in it ?
Reply With Quote
  #20 (permalink)  
Old March 17th, 2004, 05:05 AM
Registered User
 
Join Date: Mar 2004
Location: , , Hong Kong.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've tried to run the putfile in XP box, and it working fine.
Hope it help ppl. : )

                ' --------------------
                ' Transfer via standard FTP
                ServerName = strLocation.ToUpper
                FTPLogin = txtUserID.Text
                FTPPassword = txtPassword.Text

                ' Instantiate a new FTP object
                Dim INet, INetConn As Integer
                Dim RC As Boolean
                ' FTP_TRANSFER_TYPE_ASCII
                ' FTP_TRANSFER_TYPE_BINARY
                INet = InternetOpen("CTM_SMS_FTP_Control", 1, vbNullString, vbNullString, 0)
                INetConn = InternetConnect(INet, ServerName, 0, FTPLogin, FTPPassword, 1, 0, 0)
                RC = FtpPutFile(INetConn, strFileName, "\a\upload.txt", 0, 0)

                If RC Then
                    MsgBox("Transfer succesfull!")
                End If
                InternetCloseHandle(INetConn)
                InternetCloseHandle(INet)

                '------------------

Keung
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 03:02 AM
loop through tables inside .mdb file using VB.NET remya1000 General .NET 3 September 24th, 2007 01:45 PM
Start a program inside another program Silje Classic ASP Professional 1 November 16th, 2004 02:08 AM
Running FTP within VB .NET Application ocarroll General .NET 7 September 28th, 2004 05:25 PM



All times are GMT -4. The time now is 04:26 AM.


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