Page 1 of 3

Upload/Download Files

Posted: Sun Aug 23, 2009 12:38 am
by CodenStuff
Hello,

This snip will show you the simple way of Downloading and Uploading files to/from a website.

First you need to have 2 imports at the top of your code:
Code: Select all
Imports System.Net
Imports System.IO
Then use the following codes to do the corresponding action.

Download a file:
Code: Select all
My.Computer.Network.DownloadFile("http://www.WEBSITE.com/NameOfFile.ext", "SaveAs.ext")

Uploading a file:
Code: Select all
My.Computer.Network.UploadFile("FileToUpload.ext", "ftp://www.WEBSITE.com/StoreFileAs.ext", "USERNAME", "PASSWORD", True, 10, FileIO.UICancelOption.DoNothing)

And thats all you need to do. Simple and easy.

Happy Coding.

Re: Upload/Download Files

Posted: Thu Aug 27, 2009 5:08 pm
by Martin
This Code Works Great Vhite My New Program

Re: Upload/Download Files

Posted: Fri Sep 11, 2009 7:20 pm
by Nery
I used your snippet to successfully produce a Youtube Video Downloader ^^

Guess what... Both uploading and downloading videos works! :D

Re: Upload/Download Files

Posted: Fri Sep 18, 2009 5:52 pm
by CodemaN
thanks man great job

Re: Upload/Download Files

Posted: Sun Sep 20, 2009 8:00 am
by Martin
how did you make a youtube video uploder?

martin64 :D

Re: Upload/Download Files

Posted: Sun Sep 20, 2009 2:21 pm
by Nery
Not uploader, I said DOWNLOADER ^^

Well, since youtube downloads itself the videos for each time you see them you can use the feed you're receiving from youtube to save the file in your desktop instead of making a temporary file in your internet browser's cookies folder.

Re: Upload/Download Files

Posted: Sun Oct 11, 2009 5:57 pm
by Neki
Great snippet! I like it!

Re: Upload/Download Files

Posted: Mon Nov 09, 2009 10:02 pm
by GoodGuy17
I don't get this part:
My.Computer.Network.DownloadFile("http://www.WEBSITE.com/NameOfFile.ext", ">>SaveAs.ext<<")
What should I change SaveAs.ext to? .exe? or what? Give me an example please.

Re: Upload/Download Files

Posted: Tue Nov 10, 2009 12:39 am
by CodenStuff
Hello,

Thats the name of the file you want to save it as on your computer. For example if I wanted to download a file from the website called "Application.zip" and I wanted to save it on my computer as "MyApp.zip" I would use the code like this:
Code: Select all
My.Computer.Network.DownloadFile("http://www.WEBSITE.com/Application.zip", "MyApp.zip")
So the first part is the URL and name of the file you want to download. The second part is what you want to save the file as when its downloaded.

Hope that helps cooll;

Re: Upload/Download Files

Posted: Tue Nov 10, 2009 12:42 am
by GoodGuy17
Thanks,
But the problem NOW is, say my code is this:
My.Computer.Network.DownloadFile(TextBox1.Text, ">>>MyApp.zip<<<")
How can I make my program figure out what the extension is?
I think I have an IDEA of what to do:
My.Computer.Network.DownloadFile(TextBox1.Text, TextBox2.Text)
And make the user type what they want to save it as(the name) AND the extension at the end?