Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16044

VS 2019 CefSharp Download Handler

$
0
0
I am trying to get the download handler working in CefSharp. I think i am missing something obvious. In the following example, the browser works, the download handler does not fire when clicking on a link, nor does the file download.

Code:

Imports CefSharp
Imports CefSharp.WinForms
Imports Microsoft.VisualBasic.FileIO

Public Class Form1

    Private WithEvents Chromium As ChromiumWebBrowser
    Private WithEvents Download_Handler As New Download_Handler

    Sub Form_Load(ByVal Caller As Object, ByVal Arguments As System.EventArgs) Handles MyBase.Load
        Chromium = New ChromiumWebBrowser("ftp://ftp.cert.dfn.de/pub/docs/FAQ/cryptography-faq/")
        Controls.Add(Chromium)
    End Sub

    Shared Sub Download_Finished() Handles Download_Handler.Finished
        Debug.WriteLine("Finished")
    End Sub
End Class

Public Class Download_Handler
    Implements IDownloadHandler

    Public Event Finished()

    Public Sub Before(Chromium As IWebBrowser, Browser As IBrowser, Item As DownloadItem, Callback As IBeforeDownloadCallback) Implements IDownloadHandler.OnBeforeDownload
        Debug.WriteLine("Before")
        If Not Callback.IsDisposed Then Callback.Continue(IO.Path.Combine(SpecialDirectories.Desktop, Item.SuggestedFileName), True)
    End Sub

    Public Sub Updated(Chromium As IWebBrowser, Browser As IBrowser, Item As DownloadItem, Callback As IDownloadItemCallback) Implements IDownloadHandler.OnDownloadUpdated
        Debug.WriteLine("Updated")
        If Item.ReceivedBytes > 0 Then RaiseEvent Finished()
    End Sub
End Class

I'm trying to keep this as simple as possible, so i can learn what is needed and what is not. What am i missing?

Viewing all articles
Browse latest Browse all 16044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>