By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

HowTo, Download first 1024 bytes of file ONLY?

P: n/a
Basically, the title explains it.

I want to be able to read the first n bytes (say, 1024 bytes) of any
file (text or binary) off the internet in my application. I
specifically do not want to download the whole file (which in most
cases will be significantly large compared to the portion i do want).

I've looked into only to find that the
OpenReadAsync methods doesn't even have a ProgressChanged event, and
I've looked into DownloadDataAsync method only to find that there is
a DownloadProgressChanged event but it doesn't actually pass the
buffered data to anything (and so you can't grab the start of the data
and then cancel the remaining transfer). There is a
DownloadDataCompleted event which is fired if you cancel the transfer
prematurely, however, in cases where the transfer is cancelled or there
is a transfer error, NON of the data transfered is actually passed to
this function either (transfer must complete for you to be able to
access the data through the DownloadDataCompletedEventArgs.Result

This is really disappointing, you'd figure these issues would be
clearly documented (but they are not and it really is guess work +
trial & error with ms these days - still). If they can't document such
a comprehensive framework sufficiently, maybe they shouldn't provide
101 classes to download files where not one can be rendered into
downloading a partial file.

Ok, I've had my moment of publicly whining (this is what happens
after 3-full days of performing errant google searches).

Could anyone point me in the right direction? I'm sure it would be a
generally useful post since there is a lack of discussion of this
anywhere on the internet. Something like this could also be useful for
resumable downloads, resumable downloading especially in the area of
creating an application that would support this.



Mar 27 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.