Download a File From an URL

Friday, December 26, 2008

Imports System
Imports System.Configuration
Imports System.Resources ' Resource readers
Imports System.Net.WebClient
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim flag As Boolean = False
Dim name As String = ""
Dim number As Integer = 0
Dim FTPC As New System.Net.WebClient
Dim callerFilename As String
Dim Downloadto As String
Dim DownloadtoFolder As String
callerFilename = "default.aspx"
DownloadtoFolder = Application.StartupPath & "\"
Downloadto = DownloadtoFolder & "\" & callerFilename
Dim strURL = "http://www.yourwebsite.in/default.aspx"
MsgBox(strURL)
Dim sysWebClient As System.Net.WebClient = New System.Net.WebClient
If Not Directory.Exists(DownloadtoFolder) Then
Directory.CreateDirectory(DownloadtoFolder)
End If
sysWebClient.DownloadFile(strURL, Downloadto)
End Sub
End Class

0 comments

Post a Comment