Is there an easy method to process the loaded data while the download is still running? I do not want to wait for the download to finish to have the whole data on memory or disk before processing. I want to do this because my data is compressed, and I'd like to decompress the byte packets on the run and write them then directly onto disk. So that I never use more memory than one download packet.
I tried to get along with the WebClient class but I didn't find out how to access the last loaded bytes in the DownloadProgressChanged event.
Something like this:
WebClient wc = new WebClient();
Uri uri = new Uri(myURL);
wc.DownloadProgressChanged += wc_DownloadProgressChanged;
wc.DownloadDataAsync(uri);
...
void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
ProcessData(e.Bytes,e.BytesReceived); //e.Bytes should access the downloaded byte packet
//but it doesn't exist
}
I figured it already out using libcurl, but I'd like to know if it's possible without using external libraries.