473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How can I know when a file has been downloaded?

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!
Jul 18 '08 #1
4 1691
On Jul 18, 10:09*am, lichaoir <licha...@gmail.comwrote:
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 ...
Jul 18 '08 #2
On Jul 18, 4:09*am, lichaoir <licha...@gmail.comwrote:
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!
Response.OutputStream.Write has been completed because the server sent
the whole file to a client. The client is still receiving the data and
I think you can try to check this using Response.IsClientConnected

http://msdn.microsoft.com/en-us/libr...connected.aspx
Jul 18 '08 #3
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)

lichaoir wrote:
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!
Jul 18 '08 #4
"lichaoir" <li******@gmail.comwrote in message
news:23**********************************@j33g2000 pri.googlegroups.com...
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?
As Bruce has correctly explained, there really is no accurate way of doing
this...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 18 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joshua | last post by:
Is there a way to set up Apache to invoke a PHP equest when a file (a image for example) is downloaded? Say, then, that http://www.foo.com/downloads/app1.zip is downloaded, Id like to have...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
7
by: TJoker .NET | last post by:
I'm developing an VB.NET Windows Forms application that uses CR for VS.NET (original version shipped with VS.NET 2002 - my VS.NET has the latest SP installed, no SPs for CR). My reports get their...
7
by: chad | last post by:
let's say I'm transferring a large file like 100MB over to a folder. The program detects when the file arrives. However, I can't figure out how to know when the file is totally transferred over....
2
by: comp.lang.php | last post by:
class ReportGenerator { function ReportGenerator() {} /** * Generate the HTTP headers necessary for this file type. Can be called statically *
7
by: eventuranza | last post by:
For my application, there users can upload and download files to the a webserver. Straightforward enough. However, when they upload a PDF file then try to download it, the file seems to be...
8
by: Peter Gustafsson | last post by:
Hi I have a HTML-only file, and asp file that do a databasequery. How can I do a query in the html file, like this: DBLookup("2"). The asp file execute the query and respond with the result....
8
by: rdemyan via AccessMonster.com | last post by:
Anyone have any ideas on how to determine when the back-end file (containing only tables) has been updated with new data. The date/time of the file won't work because it gets updated to the...
3
by: bfmcfarlane | last post by:
I have an appication that allows users to upload and download files. This application is only accessed when a user clicks on an "Upload / Download" link from within our main application. A new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.