BP Forums
Downloading from FTP server doesn't work - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Downloading from FTP server doesn't work (/showthread.php?tid=803)



Downloading from FTP server doesn't work - brco900033 - 08-12-2013

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


Re: Downloading from FTP server doesn't work - brandonio21 - 08-12-2013

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]


Re: Downloading from FTP server doesn't work - brco900033 - 08-13-2013

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!


Re: Downloading from FTP server doesn't work - brco900033 - 08-15-2013

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


Re: Downloading from FTP server doesn't work - brandonio21 - 08-15-2013

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.


Re: Downloading from FTP server doesn't work - brco900033 - 08-16-2013

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