Downloader

Posts 1–4 of 4 · Page 1 of 1
Downloader
Im making a web browser(its posted in the "Post your web browsers here" thread) and i wanna know how i can create a special downloader for my web browser, so when someone clicks a download, i can have my own downloader, thanks
On the Form's class, add this code:
[highlight=vb.net] Private Sub WebBrowser1_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs ) Handles WebBrowser1.Navigating
'Credits to lubos hasko and Michael Sun [MSFT] for this code
'I, master131 wrote the comments btw :3

'This code checks whether the object being loaded is just a HTML file (or some other object) or an actual file being downloded
'Please note that this code will only catch file extension types that are recognised by the OS
'Some extensions that are natively supported by the browser such as .txt files are not supported
'If you want to catch specific file types that aren't supported then use this code as an example:
'If e.Url.Segments(e.Url.Segments.Length - 1).EndsWith(".extensionHere") Then
' e.Cancel = true
' 'Blah, use the URL, whatever
'End If
'I recommend you do not use HTML or PHP files with the above code as it can totally fuck up your browser.
'Also take note that the ABOVE code won't be able to catch every file that ends with a specific
'extension as some download links may look like this: http://www.somesite.com/download/file/fsd352m234ma4

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(e.Url)
request.Method = "HEAD"
Dim response As System.Net.WebResponse = request.GetResponse()

If response.ContentType = "application/octet-stream" Or response.ContentType.StartsWith("image/") Then
e.Cancel = True
'Do crap with the link here
'Use: e.Url.ToString to obtain the download link
'For example, you could create a form that downloads files. Then just simply pass the link over from here to the other form and profit??
End If
response.Close()
End Sub[/highlight]
that code when i copy and paste it all goes into one line...
EDIT: Nevermind, i just had to Quote your port and copy the text that way, worked perfect, thanks bro
Or you could just use GeckFX as your rendering engine (it makes your browser faster and from what iv heard it comes with download manager)
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us