C# 2.0 download file's status

J

Jason Huang

Hi,

In my .Net 2.0 C# web project, I have files for user to download.
How do I know the downloading status for a particular file?
I mean the file is being downloading ,or is downloaded completely, or
partially downloaded then break.
Thanks for help.


Jason
 
H

Hilton

In pseudo-code:

Send (STARTING);
Open Streams
while (Not finished reading)
{
Read bytes
Write bytes
Send (STATUS)
}
finally
{
Close Streams
}
Send (FINISHED)

I suggest you put this in its own thread and if you do, then ensure that
nothing in Send does anything UI-related.

Hilton
 
J

Jon Skeet [C# MVP]

In pseudo-code:

I suggest you put this in its own thread and if you do, then ensure that
nothing in Send does anything UI-related.

That sounds applicable for a WinForms application, but not web. To be
honest, there's not a lot you can do in a web app without some sort of
custom downloader, as far as I'm aware.

If you write the data unbuffered (which is sensible - you don't want
the whole file loaded in memory before being sent) then I suspect
you'll have *some* idea of how much the client has got based on how
much data you've sent - it'll block at some point. I'd expect it to be
pretty imprecise due to buffering elsewhere though.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top