public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { //downloadPath, show default download dialog //callback.Continue(downloadItem.SuggestedFileName, showDialog: true); WebDownload manager = new WebDownload(); manager.FileToDownload = downloadItem.Url; manager.Show(); } } }
public int Download([In, MarshalAs(UnmanagedType.Interface)] IMoniker pmk, [In, MarshalAs(UnmanagedType.Interface)] IBindCtx pbc, [In, MarshalAs(UnmanagedType.U4)] uint dwBindVerb, [In] int grfBINDF, [In] IntPtr pBindInfo, [In, MarshalAs(UnmanagedType.LPWStr)] string pszHeaders, [In, MarshalAs(UnmanagedType.LPWStr)] string pszRedir, [In, MarshalAs(UnmanagedType.U4)] uint uiCP) { string name = string.Empty; pmk.GetDisplayName(pbc, null, out name); if (!string.IsNullOrEmpty(name)) { Uri url = null; bool result = Uri.TryCreate(name, UriKind.Absolute, out url); if (result) { WebDownload manager = new WebDownload(); manager.FileToDownload = url.AbsoluteUri; manager.Show(); return 0; } } return 1; }