Home All Groups Group Topic Archive Search About

Download tif from the web via a stream with progress indication

Author
7 Sep 2006 1:41 PM
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

Author
7 Sep 2006 7:59 PM
gene kelley
Show quote Hide quote
On Thu, 7 Sep 2006 08:41:05 -0500, "Lance" <chuckyboy81070-at-onehotpotatoimeanhotmail.com> wrote:

>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
Author
7 Sep 2006 8:34 PM
Lance
Thanks Gene.  I'll look into that.

Lance

Show quoteHide quote
"gene kelley" <o***@by.me> wrote in message
news:gps0g2th29uqr19ktsc4f1lsn2o70p7dbt@4ax.com...
> On Thu, 7 Sep 2006 08:41:05 -0500, "Lance"
> <chuckyboy81070-at-onehotpotatoimeanhotmail.com> wrote:
>
>>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