Translating my answer to C# Download all files and subdirectories through FTP to VB.NET: The FtpWebRequest does not have any explicit support for recursive file download (or any other recursive operation). You have to implement the recursion yourself: List the remote directory. VB Files ยป Directory; Drive. FTP (File Transfer Protocol) is used for exchanging files over the Internet. Start Visual Basic and create a Visual Basic Windows Forms application. Add four buttons to your form. 'Download A File From FTP Site' Private Sub Button2_Click(sender As Object, e As EventArgs) _ Handles Button2.Click.
I'm using Microsoft's own VB.NET FTP Example: I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a 'Cannot connect to remote server' error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port) Try s.Connect(ep) Catch ex As Exception MessageString = msReply Throw New IOException('Cannot connect to remote server.' ) As I said, it'll do a directory list, create, change, and delete directories, but it will NOT transfer a file, and that's what I need it to do. I have the code set up properly for VS 2003, per the comments for the port calculations, and even tried it the VS 2002 way just to be sure that wasn;t the problem.
I've also tried the Indy FTP client, but it won't even do a directory list (says the machine 'actively refused' the connection). If someone could help I'd appreciate it. (please send all replies via the newsgroup) Dim the Lights & Save the Stars. Hi Jen, This apparently seems to be the connectivity issue. Try to access the FTP using command prompt without using some FTP explorer.
If that doesnt work then the issue is with the connectivity (firewall or something ) rather than code problem. HTH rawCoder 'Jen' wrote in message news:[email protected].
I'm using Microsoft's own VB.NET FTP Example: I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a 'Cannot connect to remote server' error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port) Try s.Connect(ep) Catch ex As Exception MessageString = msReply Throw New IOException('Cannot connect to remote server.' ) As I said, it'll do a directory list, create, change, and delete directories, but it will NOT transfer a file, and that's what I need it to do. I have the code set up properly for VS 2003, per the comments for the port calculations, and even tried it the VS 2002 way just to be sure that wasn;t the problem. I've also tried the Indy FTP client, but it won't even do a directory list (says the machine 'actively refused' the connection). If someone could help I'd appreciate it.
(please send all replies via the newsgroup) Dim the Lights & Save the Stars. Hi, The files that it tries to upload dont exist on my machine. I had to create them.
Are you the files you are trying to upload exist? Ken - 'Jen' wrote in message news:[email protected]. I'm using Microsoft's own VB.NET FTP Example: I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server.
I just get a 'Cannot connect to remote server' error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port) Try s.Connect(ep) Catch ex As Exception MessageString = msReply Throw New IOException('Cannot connect to remote server.' ) As I said, it'll do a directory list, create, change, and delete directories, but it will NOT transfer a file, and that's what I need it to do. I have the code set up properly for VS 2003, per the comments for the port calculations, and even tried it the VS 2002 way just to be sure that wasn;t the problem. I've also tried the Indy FTP client, but it won't even do a directory list (says the machine 'actively refused' the connection). If someone could help I'd appreciate it.
(please send all replies via the newsgroup) Dim the Lights & Save the Stars. I think I have it working (so far anyway). It wasn't the code at all - it was the server I was connecting to. Unbeknownst to me, comcast had changed the name of their FTP servers from 'mywebpages.comcast.net' to 'upload.comcast.net'.
Evidently it's still a work in progress, as the 'mywebpages' server will still come up for directory functions, but won't allow me tp upload. Thanks to everyone that tried to help, I do appreciate it! (please send all replies via the newsgroup) Dim the Lights & Save the Stars. Jen, Is it working? I have the same problem - in the MS app, an error comes up when trying to create a data socket (your given code). I manage to trace it to one of two causes: the target machine actively refusing connection, or just taking too long to respond. For some reason, the error returned is the more general (and vague) 'Cannot connect to remote server'.
Damn irritating. But I've tried it with four different FTP sites having verified usernames and passwords and no-go. Unlikely that all four server names are changing. So if you have since figured it out, I'd appreciate you letting me know any discoveries you've since made.
Cheers, Richard PS! Is the 'dim the lights' msg your own or an advertising blurb? 'Jen' wrote: I think I have it working (so far anyway). It wasn't the code at all - it was the server I was connecting to. Unbeknownst to me, comcast had changed the name of their FTP servers from 'mywebpages.comcast.net' to 'upload.comcast.net'. Evidently it's still a work in progress, as the 'mywebpages' server will still come up for directory functions, but won't allow me tp upload.
Thanks to everyone that tried to help, I do appreciate it! (please send all replies via the newsgroup) Dim the Lights & Save the Stars. Here goes a 2nd time (MS just dropped my first reply). I've had the same problem. By examing the error messages in the debugging window when it got to the code sample you displayed (the create data socket procedure), it seems to say either that the connection was actively refused by target machine, or that it took too long to respond. Now I've tried this with 3 other FTP fites and the same error occurs, so it's unlikely that the FTP servers are all renaming their servers in my case. Is your problem fixed?
If it wasn't the server being renamed, did you find out what the problem was? I'd really appreciate your help, since this is driving me crazy. Cheers, Richard PS! The Dim the Lights msg your own, or was that advertising blurb? 'Jen' wrote: I'm using Microsoft's own VB.NET FTP Example: I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a 'Cannot connect to remote server' error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port) Try s.Connect(ep) Catch ex As Exception MessageString = msReply Throw New IOException('Cannot connect to remote server.'
) As I said, it'll do a directory list, create, change, and delete directories, but it will NOT transfer a file, and that's what I need it to do. I have the code set up properly for VS 2003, per the comments for the port calculations, and even tried it the VS 2002 way just to be sure that wasn;t the problem. I've also tried the Indy FTP client, but it won't even do a directory list (says the machine 'actively refused' the connection). If someone could help I'd appreciate it. (please send all replies via the newsgroup) Dim the Lights & Save the Stars.
Hi Scorpion, You on the ball today or what? You're almost quicker than autoreply. I can't hand out usernames and passwords, but let me try with an FTP site open to both of us, like The sample app I'm using (from the MS Site) requires me to enter a username and password and doesn't allow empty strings for anonymous logins. I can't see how to change the code to just skip this and allow anonymous logins - is there a generic anonymous username? I'd attach the project, but I can't see how, and you've probably got basically the same setup on your computer. Thanks for your time.
Cheers, Richard 'scorpion53061' wrote: Richard, I use this code every day in several apps and it works fine. Can you provide a sample address or something I can test against that is giving you problems? Hello Richard, No I just happened to be online when you were and have a particular interest in this subject because I struggled with this for so long. I will do some testing now that I understand your problem.
You need to be able to FTP without authentication being required as I understand it. Let me do some work and I will get back to you. 'RichardC' wrote in message news:67.@microsof t.com: Hi Scorpion, You on the ball today or what? You're almost quicker than autoreply. I can't hand out usernames and passwords, but let me try with an FTP site open to both of us, like The sample app I'm using (from the MS Site) requires me to enter a username and password and doesn't allow empty strings for anonymous logins.
I can't see how to change the code to just skip this and allow anonymous logins - is there a generic anonymous username? I'd attach the project, but I can't see how, and you've probably got basically the same setup on your computer. Thanks for your time. Cheers, Richard 'scorpion53061' wrote: Richard, I use this code every day in several apps and it works fine. Can you provide a sample address or something I can test against that is giving you problems? Hello Richard, No I just happened to be online when you were and have a particular interest in this subject because I struggled with this for so long. I will do some testing now that I understand your problem.
You need to be able to FTP without authentication being required as I understand it. Let me do some work and I will get back to you. 'RichardC' wrote in message news:67.@microsof t.com: Hi Scorpion, You on the ball today or what? You're almost quicker than autoreply. I can't hand out usernames and passwords, but let me try with an FTP site open to both of us, like The sample app I'm using (from the MS Site) requires me to enter a username and password and doesn't allow empty strings for anonymous logins. I can't see how to change the code to just skip this and allow anonymous logins - is there a generic anonymous username?
I'd attach the project, but I can't see how, and you've probably got basically the same setup on your computer. Thanks for your time. Cheers, Richard 'scorpion53061' wrote: Richard, I use this code every day in several apps and it works fine.
Can you provide a sample address or something I can test against that is giving you problems? Scorpion, I feel like FTP is the real sting in the tail. The site that I'm working with does require authentication, but obviously my work would not be happy with me just handing it out. The principal remains the same, though. So, I'd like to replicate the problem with a site we can both test with, ftp.microsoft.com for example.
I just downloaded the popular Indy application as well, and put in the MS ftp site and username anonymous and no password. It won't get around to transferring data, although I suspect the connection IS being formed (reading the messages sent back and forth seem to confirm this), once it gets to sending data, as in a directory listing, it says that it's taking too long for the server to respond. So I can't ACTUALLY verify that the connection is rock solid. Cheers, Richard.
When I attempt to connect to the MS ftp site I also experience problems. When I attempt to connect to my FTP servers or other FTP servers I don't have a problem. I will keep working.
'RichardC' wrote in message news:95.@microsof t.com: Scorpion, I feel like FTP is the real sting in the tail. The site that I'm working with does require authentication, but obviously my work would not be happy with me just handing it out. The principal remains the same, though. So, I'd like to replicate the problem with a site we can both test with, ftp.microsoft.com for example.
I just downloaded the popular Indy application as well, and put in the MS ftp site and username anonymous and no password. It won't get around to transferring data, although I suspect the connection IS being formed (reading the messages sent back and forth seem to confirm this), once it gets to sending data, as in a directory listing, it says that it's taking too long for the server to respond. So I can't ACTUALLY verify that the connection is rock solid. Cheers, Richard. I tried using the default Indy address - ftp.netscape.com and same thing. Makes me want to throw the computer out of the 26th floor that I work on. The error was: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'.
It's odd, because I can navigate my way using IE and I'm fairly surely now that the connection IS forming. It just refuses to send data (maybe something wrong with the data port usage). My connection definitely appears to be passive. I've chatted with the IT guy to see if I was lacking rights or if the firewall might be interfering, but he is fairly sure that isn't the problem.
I do appreciate your help. Thanks again. Richard, read ur posts, i m having exactly same problem.
Hv u found anything? 'RichardC' wrote: Jen, Aargh! Here goes a 2nd time (MS just dropped my first reply). I've had the same problem.
By examing the error messages in the debugging window when it got to the code sample you displayed (the create data socket procedure), it seems to say either that the connection was actively refused by target machine, or that it took too long to respond. Now I've tried this with 3 other FTP fites and the same error occurs, so it's unlikely that the FTP servers are all renaming their servers in my case.
Is your problem fixed? If it wasn't the server being renamed, did you find out what the problem was? I'd really appreciate your help, since this is driving me crazy.
Cheers, Richard PS! The Dim the Lights msg your own, or was that advertising blurb? 'Jen' wrote: I'm using Microsoft's own VB.NET FTP Example: I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server.
I just get a 'Cannot connect to remote server' error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ep = New IPEndPoint(Dns.Resolve(ipAddress).AddressList(0), port) Try s.Connect(ep) Catch ex As Exception MessageString = msReply Throw New IOException('Cannot connect to remote server.' ) As I said, it'll do a directory list, create, change, and delete directories, but it will NOT transfer a file, and that's what I need it to do. I have the code set up properly for VS 2003, per the comments for the port calculations, and even tried it the VS 2002 way just to be sure that wasn;t the problem. I've also tried the Indy FTP client, but it won't even do a directory list (says the machine 'actively refused' the connection).
If someone could help I'd appreciate it. (please send all replies via the newsgroup) Dim the Lights & Save the Stars.
FTP Upload In this tutorial, we cover uploading files to an FTP server using Visual Basic.NET.