Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Downloading from FTP server doesn't work
#1
I have been working on a little project that requires downloading a file from an FTP server. The problem is that it just doesn't want to work. I have uploaded my project so you guys can read the whole code because I found a library online.

Also you can acces the FTP I'm using for this test project, it is just a test server so you can't acces any of my normal files, only the file that has to be downloaded.

Now the problem; in this test project I created two buttons, the first one downloads the file with the standard future of VB.NET(FtpWebRequest). The problem is that it says that the file is downloaded but the file isn't saved anywhere on the harddisk.

The second button downloads the file using the library I've found online. Everything goes fine until it gives me the error that the file doesn't exist or that I don't have the rights to acces the file (Error code 550).

I had some more problems with downloading this file but found a solution by myself but this just won't work. I really have no clue on what I'm doing wrong.

Hope someone can help me with this one,
Brecht


Attached Files
.rar   TestDownloadFTP.rar (Size: 157.83 KB / Downloads: 677)
#2
I think that you are over-complicating things a bit! I worked with the My.Computer.Network.DownloadFile command and it seemed to have worked. For reference, the exact command you're looking for is:

[code2=vbnet]My.Computer.Network.DownloadFile("WebURL", "LocalPath", "Username", "Password", False, 9999999, True)[/code2]

I have updated the project and have reuploaded it with a new button. Hopefully this helps you out a bit.

[attachment=0]<!-- ia0 -->TestDownloadFTP.rar<!-- ia0 -->[/attachment]


Attached Files
.rar   TestDownloadFTP.rar (Size: 161.57 KB / Downloads: 549)
My Blog | My Setup | My Videos | Have a wonderful day.
#3
No way, that one line of code does it? How come I never found that.

Okay, well now I agree that I complicated it way too much, for the downloading part. But I have some other actions to perform that I don't think they are that easy so I decided to use this library. I have to do things like checking if a file exists on the server and downloading all files from a specific directory(on the server). I did not tested these last actions because I was to busy trying to download a file, but I will test them right away.


I'm sooo happy that I can finally download a file from my server, thanks for that! But I still don't understand why the FtpWebRequest and the library doesn't work. After all it gives you the same result, right?

Many thanks, Brecht!
#4
I discovered what caused the exception accidently while playing with the code.

The truth is that the library works perfect but it was my own mistake. I got an error that says the file wasn't found so I checked my server and saw that the file was stored correctly and with the required permissions. What the actuall mistake was, was a wrong path to the file (the path that I had to enter myself in order to download the file).

This was my mistake:
Code:
Dim ftpDownloader As New FTPClient.Utilities.FTP.FTPclient("host", "username", "password")
        ftpDownloader.Download("/public_html/Current_NewVersion.txt", "C:\test_file.txt", True)
        MsgBox("succes")
As you can see the path I entered contains /public_html and this is simply not necessary.

That was the error I was trying to fix for days... <!-- s:twisted: --><img src="{SMILIES_PATH}/icon_twisted.gif" alt=":twisted:" title="Twisted Evil" /><!-- s:twisted: -->
#5
Ah, darn! I should have caught that! I used to make the same mistake that you just encountered all the time. But I am glad that you got it figured out in the end! After all, 90% of programming consists of working out bugs that you yourself created!

But I'm glad you got it worked out.
My Blog | My Setup | My Videos | Have a wonderful day.
#6
Another mistake I used to make with this library is that I entered my host like this <!-- m --><a class="postlink" href="ftp://test_server">ftp://test_server</a><!-- m -->/
but the last '/' is one too much.

But it works fine now, the library does a good job after all...


Possibly Related Threads…
Thread Author Replies Views Last Post
  multiple csv files add sql server tables via VB.NET secilsengul 1 9,980 04-16-2014, 10:27 AM
Last Post: brco900033
  How can I get the server status??? mnxford 5 23,737 03-27-2013, 10:53 AM
Last Post: mnxford
  Is this possible with SQL Server? Worf 2 12,338 02-25-2013, 03:04 AM
Last Post: Worf
  Sockets Programming(Disconnecting from Server) xolara 1 9,439 04-06-2012, 01:47 PM
Last Post: brandonio21
  Why dusn't this code Work? Aaron Rogers118 3 13,981 02-21-2012, 03:04 PM
Last Post: Aaron Rogers118

Forum Jump:


Users browsing this thread: 1 Guest(s)