473,473 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Questions re System.IO.FileStream

Hi guys

I'm trying to code up a file downloading system for our website (C#).

My basic plan is that when a user clicks a file download, a page opens that
shows something, and fires the chunked file download (via FileStream).

That wroks fine, but what I want is a situation where if window that started
the download is closed, the streaming stops. IE the download stops.

Currently, I'm using the C# code from this KB article..
http://support.microsoft.com/kb/812406 - as I say, the download fires ok.

The question is, how do I stop it before it finshes?! Is it even possible,
or am I gonna have to do it in Silverlight?!

Thanks,
Dan
Jan 24 '08 #1
2 1570
Try using the Response.IsClientConnected property.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"musosdev" wrote:
Hi guys

I'm trying to code up a file downloading system for our website (C#).

My basic plan is that when a user clicks a file download, a page opens that
shows something, and fires the chunked file download (via FileStream).

That wroks fine, but what I want is a situation where if window that started
the download is closed, the streaming stops. IE the download stops.

Currently, I'm using the C# code from this KB article..
http://support.microsoft.com/kb/812406 - as I say, the download fires ok.

The question is, how do I stop it before it finshes?! Is it even possible,
or am I gonna have to do it in Silverlight?!

Thanks,
Dan
Jan 24 '08 #2
you will need to do a server push solution. on the main window, using a
hidden iframe, hit a page, that pushes data to the client (unbuffered and
flush()), that can detect a closed connection. it should also poll for the
download status from the download page so it knowns when to close. if the
connection is closed then it can notify the download page. the download page
must also use unbuffered output so it can stop.

one last detail is that only one of the pages can use session (as the
requests to the same session are queued).

-- bruce (sqlwork.com)
"musosdev" wrote:
Hi guys

I'm trying to code up a file downloading system for our website (C#).

My basic plan is that when a user clicks a file download, a page opens that
shows something, and fires the chunked file download (via FileStream).

That wroks fine, but what I want is a situation where if window that started
the download is closed, the streaming stops. IE the download stops.

Currently, I'm using the C# code from this KB article..
http://support.microsoft.com/kb/812406 - as I say, the download fires ok.

The question is, how do I stop it before it finshes?! Is it even possible,
or am I gonna have to do it in Silverlight?!

Thanks,
Dan
Jan 24 '08 #3

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

Similar topics

7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
4
by: Scott, Killer of all Ninjas | last post by:
It seems incredulous to me that it is so difficult to write the contents of a memory stream to a file. I'm certain that I'm missing something simple. I am retrieving a memory stream from a DIME...
1
by: liran | last post by:
hello i am trying to create a new file and then to write to it. how can i create an new file? i tried System . IO.File but it returns an error as follows: System.IO.File.File() is inaccessible...
1
by: Patrick | last post by:
When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace file, and I can't read the trace file without restarting the IIS: Even the following does NOT work (how could I fix...
9
by: ljlevend | last post by:
I have two questions related to FileStreams. 1. Is there any way to determine whether a file has the permissions that are required by a FileStream constructor? For example, given the following...
6
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged...
0
by: The Confessor | last post by:
I'm relatively new to using FileStreams, so bear with me. I'm trying to use the following code Dim MapGraphicsFileStream As New System.IO.FileStream(MapGraphicsFile, System.IO.FileMode.Create)...
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.