-
Feb 4th, 2011, 01:41 PM
#1
Thread Starter
Lively Member
[RESOLVED] How to stop download once started it
Hi,
I created a form which,through the input of a URL via a textbox, downloads a file from the internet. For example I write in the textbox
http://www.downloadfile.com/filetobedownloaded.rar
and after I hit the download button the software starts downloading the file (the progress is shown via a progress bar).
What about if I want to stop the download before the download is over?
How can I do it? What should I write in the "Stop" button?
Thank you in advance,
Andrea
-
Feb 4th, 2011, 02:02 PM
#2
Re: How to stop download once started it
Which method do you use to download the file?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2011, 02:33 PM
#3
Thread Starter
Lively Member
Re: How to stop download once started it
Private WithEvents _Downloader As WebFileDownloader
Try
_Downloader = New WebFileDownloader
_Downloader.DownloadFileWithProgress("URL" & ComboBox1.Text & ".rar", txtDownloadTo.Text.TrimEnd("\"c) & GetFileNameFromURL("URL" & ComboBox1.Text & ".rar"))
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
-
Feb 4th, 2011, 03:59 PM
#4
Re: How to stop download once started it
Since the WebFileDownloader class is a custom type, you will have to tell us what's in it. Do you have the code for that class?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2011, 04:13 PM
#5
Thread Starter
Lively Member
Re: How to stop download once started it
Yes! here it is (I really thank you for your help):
Public Class WebFileDownloader
Public Event AmountDownloadedChanged(ByVal iNewProgress As Long)
Public Event FileDownloadSizeObtained(ByVal iFileSize As Long)
Public Event FileDownloadComplete()
Public Event FileDownloadFailed(ByVal ex As Exception)
Private mCurrentFile As String = String.Empty
-
Feb 4th, 2011, 04:24 PM
#6
Re: How to stop download once started it
Just listing the class member names won't help. Is it too much to post the full class?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2011, 04:56 PM
#7
Thread Starter
Lively Member
Re: How to stop download once started it
I resolved by writing the program back again in a different way!
This time I used .DownloadFileAsync for downloading and .CancelAsync() for stopping the download.
Last edited by Netmaster; Feb 5th, 2011 at 03:48 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|