How can I know when a file has been downloaded?


L

lichaoir

Hmm... What I really mean is...

I want to write a program to monitor file downloading. I want to be
notified when a file has been downloaded, so I can write a record into
database. How should I implement this?

My colleague has written a program, but is has some problem:

-------------------------------------------------------------------------------------------------------------------------------------------
Response.BufferOutput = false;
FileStream fs = File.OpenRead(Server.MapPath("~/test1.zip"));
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
Response.OutputStream.Write(data, 0, data.Length);

fs.Close();
fs.Dispose();

// Add a record to database......
 
Ad

Advertisements

J

jashin724

Hmm... What I really mean is...

I want to write a program to monitor file downloading. I want to be
notified when a file has been downloaded, so I can write a record into
database. How should I implement this?

My colleague has written a program, but is has some problem:

---------------------------------------------------------------------------­----------------------------------------------------------------
        Response.BufferOutput = false;
        FileStream fs = File.OpenRead(Server.MapPath("~/test1.zip"));
        byte[] data = new byte[fs.Length];
        fs.Read(data, 0, data.Length);
        Response.OutputStream.Write(data, 0, data.Length);

        fs.Close();
        fs.Dispose();

        // Add a record to database......
---------------------------------------------------------------------------­----------------------------------------------------------------

The problem is, when the file is downloaded nearly 80%, a record has
already been there in database. What's the problem? Please help!
Thanks!

I don't know, I have a same problem too, I think there is something
between Response and Client, maybe IIS or Browser have some cache
or ...
 
Ad

Advertisements

B

bruce barker

there is really no way server side to know if the browser recieved the
complete file. generally there are proxy servers and firewalls between
the server and client, any of which might lose connection after the
server is done sending the file. the only way is a client app that does
the download.

-- bruce (sqlwork.com)
 

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