Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TUT]Make an Advanced File Downloader
#1
Advanced File Downloader


Ok Heres the TUT.
1.Make a new project named Advanved file downloader.
2.Add 2 buttons, a textbox, and a progress bar.
3.Name one button "Save As",and the other "Download"
4.Double click Save As and paste this code.
Code:
Dim save AsNew SaveFileDialog
save.Title = "Advanced Downloader"
save.ShowDialog()
TextBox1.Text = save.FileName

5.Double click Download and paste this code.
Code:
httpclient = New WebClient
Dim sourceurl = ("http://failblog.files.**.com/2009/12/epic-fail-7-11-fail.jpg")
Dim filedir = TextBox1.Text
ProgressBar1.Minimum = "0"
ProgressBar1.Maximum = "100"
Try
httpclient.DownloadFileAsync(New Uri(sourceurl), (filedir))
Catch ex As Exception
'do nothing
EndTry

6.Now after the "end sub" of that code paste:
Code:
PrivateSub httpclient_DownloadProgressChanged(ByVal sender AsObject, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
EndSub

Note: This is the download percent
7.Now above PublicClass Form1 paste :

Code:
Imports System.Net

8.No under public class form 1 paste:
Code:
PrivateWithEvents httpclient As WebClient

The CODE :
Code:
Imports System.Net
Public Class Form1
    Dim save As New SaveFileDialog
    Private WithEvents httpclient As WebClient
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  httpclient = New WebClient
  Dim sourceurl = ("http://failblog.files.**.com/2009/12/epic-fail-7-11-fail.jpg")
  Dim filedir = TextBox1.Text
  ProgressBar1.Minimum = "0"
  ProgressBar1.Maximum = "100"
  Try
    httpclient.DownloadFileAsync(New Uri(sourceurl), (filedir))
  Catch ex As Exception
    'do nothing
  End Try
    End Sub
    Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
  ProgressBar1.Value = e.ProgressPercentage
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  save.Title = "Advanced Downloader"
  save.ShowDialog()
  TextBox1.Text = save.FileName
    End Sub
End Class

thank's to jommla for fixing it Smile.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.NET] Advanced MessageBox Control BlackSpider 14 11,372 03-04-2015, 11:22 PM
Last Post: longwest
  [SOURCE] Advanced Webcam Viewer TalishHF 4 3,530 08-25-2014, 01:20 AM
Last Post: dark_move
  [TUT]Creating Advanced Web Browser with Awesome Theme Imaking31 0 1,320 05-25-2013, 03:12 AM
Last Post: Imaking31
  Free Advanced Port Scanner SOURCE [ VB.NET ] Filefinder 6 5,397 01-22-2013, 04:27 AM
Last Post: TalishHF
  How To make an advanced Operating System in Visual Basic 2010 ? Mohamed Samir 9 11,601 01-15-2013, 09:30 PM
Last Post: Resistance

Forum Jump:


Users browsing this thread: 1 Guest(s)