Visual Basic アプリケーションの Web ブラウザーとして、mozilla xul15 で gecko15 を使用しています。
ダウンロードを処理する方法を知っている人はいますか?
なぜなら、そのブラウザからダウンロードするファイルをクリックしても何も起こらないからです。
助けてくれてありがとう。
また: @Form LOAD イベント: 追加: AddHandler Gecko.LauncherDialog.Download、AddressOf LauncherDialog_Download
次に、Private Sub LauncherDialog_Download(ByVal sender As Object, ByVal e As Gecko.LauncherDialogEvent) e.cancel() try catch ex を例外として最後に e.Navigate(Nothing) '異常な DM 動作を防止 end try End Sub
それが役立つことを願って、
'注: 「'」を削除します
' Dim P As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\\tmp" ' If Not System.IO.Directory.Exists(P) Then System.IO.Directory.CreateDirectory(P)
' Dim objTarget As nsILocalFile = Xpcom.CreateInstance(Of nsILocalFile)("@mozilla.org/file/local;1")
' Dim tmp_Loc As String = P & "\tmpdload"
' Using tmp As New nsAString(tmp_Loc)
' objTarget.InitWithPath(tmp)
' End Using
' If e.Filename.Contains(".") Then
'S = Strings.Split(e.Filename, ".")
'F = S(S.Length - 1).ToUpper & " File (*." & S(S.Length - 1) & ")|*." & S(S.Length - 1)
'Else
' F = "File (*.*)|*.*"
'End If
' savebox.Filter = F '"HTML File (*.html)|*.html"
' savebox.Title = "Save File:"
' savebox.FileName = e.Filename
' If savebox.ShowDialog = System.Windows.Forms.DialogResult.OK And Not String.IsNullOrEmpty(savebox.FileName) Then
' Dim source As nsIURI = IOService.CreateNsIUri(New Uri(e.Url).AbsoluteUri)
' Dim dest As nsIURI = IOService.CreateNsIUri(New Uri(savebox.FileName).AbsoluteUri)
' Dim t As nsAStringBase = DirectCast(New nsAString(System.IO.Path.GetFileName(savebox.FileName)), nsAStringBase)
'
' Dim persist As nsIWebBrowserPersist = Xpcom.CreateInstance(Of nsIWebBrowserPersist)("@mozilla.org/embedding/browser/nsWebBrowserPersist;1")
' Dim DownloadMan As nsIDownloadManager = Xpcom.CreateInstance(Of nsIDownloadManager)("@mozilla.org/download-manager;1")
' Dim downloadX As nsIDownload = DownloadMan.AddDownload(0, source, dest, t, e.Mime, 0, Nothing, DirectCast(persist, nsICancelable), False) '
' If (downloadX IsNot Nothing) Then
'persist.SetPersistFlagsAttribute(2 Or 32 Or 16384)
'persist.SetProgressListenerAttribute(DirectCast(downloadX, nsIWebProgressListener))
'persist.SaveURI(source, Nothing, Nothing, Nothing, Nothing, DirectCast(dest, nsISupports), Nothing)
'FF ダウンロード マネージャーを表示するには: 'Dim win = Xpcom.GetService(Of nsIWindowWatcher)("@mozilla.org/embedcomp/window-watcher;1") ' win.OpenWindow(Nothing, "chrome://mozapps/content /downloads/downloads.xul", "ダウンロード", "chrome,resizable=yes,hide", Nothing)