Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear All,

I would like to receive help regarding cancelling a download.

I explain my case, I have my files in website. In front end I was provided with download and cancel buttons. When I click on Download button, my zip files will start to download from website. If I click on cancel my downloading file should stop ie., cancelled. But it should not close my project instead I should be in the Form_Load screen i.e., Initial event(Gridview for further proceedings.).

How to perform this operation, does anyone overcome such issue?. I gone through background file downloader kinda articles. Its too much for my requirement. I need it very basically. Help Help Help... Let me know if you need further more assistance.
Posted
Comments
baliram bhande 12-Dec-13 6:48am    
what u have tried?
Sergey Alexandrovich Kryukov 12-Dec-13 11:52am    
It all depends on how you download. In general case, it should be your code where you download by chunks. At any chunk, you can interrupt it. Are you getting the idea? If you use some existing code which you don't understand enough to do it, it all depends on what you are using. You should download in a separate thread, but you also need to exit it gracefully somewhere in the middle of downloading. Quite a simple problem, in fact, but needs some care.
—SA
rahulaaditya 17-Dec-13 5:47am    
Hi,

I found an alternate way but I am working on it to find out whether it is effective as expected.

My idea goes like this. I use a boolean value in my cancel button. Once I click on download button the process goes in to multiple functions for downloading, extracting and writing filename in a textfile. So before each function starts firing I will checkmy bool condition if it is cancelled then i will exit my function.

Like wise I Proceeded but if i delayed clicking cancel button I sometime get stuck with that. Let me try, thanks for your suggestion.

Thanks!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900