Dim uri As New UriBuilder
uri.UserName = "xxx"
uri.Password = "xxx"
uri.Host = "xxx"
uri.Path = "xxx.aspx?q=65"
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(uri.Uri), HttpWebRequest)
request.AllowAutoRedirect = True
request = DirectCast(WebRequest.Create(DownloadUrlIn), HttpWebRequest)
request.Timeout = 10000
'request.AllowWriteStreamBuffering = True
Dim response As HttpWebResponse = Nothing
response = DirectCast(request.GetResponse(), HttpWebResponse)
Dim s As Stream = response.GetResponseStream()
'Write to disk
Dim fs As New FileStream("c:\xxx.pdf", FileMode.Create)
Dim read As Byte() = New Byte(255) {}
Dim count As Integer = s.Read(read, 0, read.Length)
While count > 0
fs.Write(read, 0, count)
count = s.Read(read, 0, read.Length)
End While
'Close everything
fs.Close()
s.Close()
response.Close()
출처 : http://stackoverflow.com/questions/6778055/how-to-use-httpwebrequest-to-download-file
'프로그래밍언어 > VB.NET' 카테고리의 다른 글
Textbox에서 Ctrl + A 사용 (0) | 2013.06.21 |
---|---|
드래그앤드롭으포 파일명표시 (0) | 2013.06.21 |
XML에 이미지 base64로 넣기 (0) | 2013.06.14 |
이미지 포맷변환 (0) | 2013.06.05 |
정규식 regex.split (0) | 2013.05.30 |