How to Download File in a Website using VB.NET

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: output 3. In your Button1 as our download button, put this code below.
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         My.Computer.Network.DownloadFile(txtInput.Text, txtOutput.Text)
  3.         '   My.Computer.Network.DownloadFile("http://www.sourcecodester.com/sites/default/files/bookapp.png", "C:\file\bookapp.png")
  4.     End Sub
Sample Input: 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: 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

Add new comment