Search code examples
vb.netwebbrowser-controlbrowser-cacheflashnavigateurl

Disable WebBrowser caching


I am new here and really want your help. I've been trying to disable my webbrowser's cache but I get overload resolution failed because no accessible "Navigate" without a narrowing conversion. I'm stuck and I don't know what to do anymore, I did search all the possible solutions but found no answer. Here's my code:

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Const navNoReadFromCache As Long = 4
        Const navNoHistory As Long = 2
        Const navNoWriteToCache As Long = 8
        Dim navflags As Long
        navflags = navNoHistory + navNoWriteToCache
        WebBrowser1.Navigate("url", 4)
    End Sub
End Class

Original Error message is:

Error 2 Overload resolution failed because no accessible 'Navigate' can be called without a narrowing conversion:

'Public Sub Navigate(urlString As String, newWindow As Boolean)': Argument matching parameter 'newWindow' narrows from 'Integer' to 'Boolean'.

'Public Sub Navigate(urlString As String, targetFrameName As String)': Argument matching parameter 'targetFrameName' narrows from 'Integer' to 'String'.

Solution

  • So after some time of searching and testing different methods I came with a good result.

    Shell("RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 8", vbHide)

    This is the code I used to delete the cache that held my web browser on a blackscreen. What it does is search for the Internet Explorer's Temporary files and deletes them, the vbHide has to be kept next to the comma to work, what is does is hide the window that pops us telling you it deletes temp files.