How to Download File in a Website using VB.NET
Submitted by donbermoy on Sunday, May 25, 2014 - 15:18.
Today, i will teach you how to create a program that can download file in a website using vb.net. This is one of my tutorials here for FTP program in VB.NET.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add only one Button named Button1 and labeled it as "Download". Insert two textboxes named txtInput for inputting the website address together with the file and txtOutput for the directory address and the folder to saved to. You must design your interface like this:
3. In your Button1 as our download button, put this code below.
Sample Input:
Here, we used the Me namespace having the computer network class and the downloadfile method of this class. The first string that we see is the website address together with the file that we have download. We have inputted "http://www.sourcecodester.com/sites/default/files/bookapp.png" from" this link Book App. The second string is the file directory in which the file that we have to be saved to. I write there "C:\file\bookapp.png". This will create a file folder and the downloaded image file will be put there. Note: we can also download any files from our source address.
Output:
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- My.Computer.Network.DownloadFile(txtInput.Text, txtOutput.Text)
- ' My.Computer.Network.DownloadFile("http://www.sourcecodester.com/sites/default/files/bookapp.png", "C:\file\bookapp.png")
- End Sub
Add new comment
- 1501 views