Download tif from the web via a stream with progress indication

  • Thread starter Thread starter Lance
  • Start date Start date
L

Lance

Hi all,

In VB6, I could use the API too query the size of a file on the web, then
download that file showing a custom progress indicator. I realize that I
can use the DownloadFile method and show a UI, but I would like to indicate
progress in my own form instead. In VB2005, how can I first get the
filesize of the web image (a tif file), then stream that image (as an array
of bytes??) to a local file while showing progress?

If all else fails, I suppose I could go the API route, but I was wondering
if there was a .Net native way to do it.

Thanks,
Lance
 
Hi all,

In VB6, I could use the API too query the size of a file on the web, then
download that file showing a custom progress indicator. I realize that I
can use the DownloadFile method and show a UI, but I would like to indicate
progress in my own form instead. In VB2005, how can I first get the
filesize of the web image (a tif file), then stream that image (as an array
of bytes??) to a local file while showing progress?

If all else fails, I suppose I could go the API route, but I was wondering
if there was a .Net native way to do it.

Thanks,
Lance

Have as look at the WebClient. I use this to simply download and then display the resulting image.

'Start the download:
WebClient1.DownloadDataAsync(some uri)

'In the WebClient1_DownloadProgressChanged is the "progress value":
MyProgress = e.ProgressPercentage

'In the WebClient1_DownloadDataCompleted event:
Dim myDatabuffer As Byte() = e.Result
Dim ms As New System.IO.MemoryStream
ms.Write(myDatabuffer, 0, myDatabuffer.Length)
bm = New Bitmap(ms, True)
Dim iWidth As Integer = bm.Width
Dim iHeight As Integer = bm.Height

PictureBox1.Image = bm


Gene
 
Thanks Gene. I'll look into that.

Lance

gene kelley said:
Have as look at the WebClient. I use this to simply download and then
display the resulting image.

'Start the download:
WebClient1.DownloadDataAsync(some uri)

'In the WebClient1_DownloadProgressChanged is the "progress value":
MyProgress = e.ProgressPercentage

'In the WebClient1_DownloadDataCompleted event:
Dim myDatabuffer As Byte() = e.Result
Dim ms As New System.IO.MemoryStream
ms.Write(myDatabuffer, 0, myDatabuffer.Length)
bm = New Bitmap(ms, True)
Dim iWidth As Integer = bm.Width
Dim iHeight As Integer = bm.Height

PictureBox1.Image = bm


Gene
 
Back
Top