C# .NET - How to stop webclient downloadfile C# .net

Asked By pramod kumar on 30-Dec-09 10:30 AM

Hi

In my program I used "webclient downloadfile" for downloading pdf files from a URL to my local machine.

Issue is while the downloading of files is in the process if I close the browser the downloading process is not stopping, can anyone please tell me how to stop downloading the files if I close the browser in middle of downloading process.

I used
WebClient myclient = new WebClient();
myclient.DownloadFile(src1, dest1);

at the end I used
myclient.dispose()

I also tried
using (WebClient myclient = new WebClient())

Please suggest me how to solve this issue.

solution

Sakshi a replied to pramod kumar on 30-Dec-09 10:46 AM

1. you need to close the download process manually

or

2. on unload event do a check and kill download process.


Thanks and Regards,
http://www.codecollege.NET

Re

Huggy Bear replied to pramod kumar on 30-Dec-09 11:40 PM
This is the default behaviour (expected one as well). Not only in your application, all the web sites having a download option behave the same way as far as I have seen. Once the download process starts, I don't think so you will have any kind of control over the download process. This could only break only if there is a network issue.