How to upload file using Geckofx 60 in VB.NET without opening dialog?

162 Views Asked by At

I'm using Geckofx 60 to fill a web form. I have to attach an image file also. I can select/click Chose file and Select a file manually. Is there any way to select a local file without opening dialog?

    Dim el As GeckoHtmlElement = GeckoWebBrowser1.DomDocument.GetElementsByTagName("input").FirstOrDefault(Function(elz) elz.GetAttribute("type") = "file")
    Dim fileNames = New IntPtr(0) {}
    Dim domInput = Xpcom.QueryInterface(Of nsIDOMHTMLInputElement)(el.DOMHtmlElement)
    domInput.MozSetFileNameArray(fileNames, CUInt(fileNames.Length)) 'Getting Error
    Marshal.ReleaseComObject(domInput)
    Dim ev As DomEventArgs = GeckoWebBrowser1.Document.CreateEvent("HTMLEvents")
    Dim webEvent = New [Event](GeckoWebBrowser1.Window.DomWindow, TryCast(ev.DomEvent, nsISupports))
    webEvent.InitEvent("change", True, True)
    el.GetEventTarget().DispatchEvent(ev)
    CustomMarshalers.WStringMarshaler().CleanUpNativeData(fileNames)

enter image description here

I have Got the Error above after checking How to choose and upload a local file to a website using Geckofx in C#?

0

There are 0 best solutions below