• We just launched and are currently in beta. Join us as we build and grow the community.

How to Download File in a Website using VB.NET

cacaocaca

Digital Trail Tracker
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
61
Likes
189
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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:

ddesign.png


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:
doutput.png


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:
download.png


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


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

336,529

336,537

Top