Private Sub DownloadFile(ByVal url As String, ByVal filePath As String)
Dim webRequest As System.Net.WebRequest = System.Net.HttpWebRequest.Create(url)
Dim webResponse As System.Net.WebResponse = webRequest.GetResponse()
Dim inputStream As System.IO.Stream = webResponse.GetResponseStream()
Dim buffer(CInt(webResponse.ContentLength) - 1) As Byte
inputStream.Read(buffer, 0, buffer.Length)
inputStream.Close()
webResponse.Close()
inputStream = Nothing
webResponse = Nothing
webRequest = Nothing
Dim fileStream As New System.IO.FileStream(filePath, IO.FileMode.CreateNew)
Dim outputStream As New System.IO.BinaryWriter(fileStream)
outputStream.Write(buffer)
buffer = Nothing
outputStream.Close()
fileStream.Close()
outputStream = Nothing
fileStream = Nothing
End Sub