2014-02-13 100 views

回答

1

我認爲對的XULrunner,CurProcD通常是安裝路徑:

var path = Components.classes["@mozilla.org/file/directory_service;1"] 
      .getService(Components.interfaces.nsIProperties) 
      .get("CurProcD", Components.interfaces.nsIFile).path; 

如果做不到這一點,你也可以嘗試resource:app

Ref:File I/O at MDN。

+0

謝謝! 'CurProcD'適用於我。 MDN表示'CurProcD'是「當前工作目錄(通常是應用程序的安裝目錄)」,但即使我在另一個目錄中使用xulrunner,我仍然從'CurProcD'獲得應用程序的安裝目錄。 xulrunner是否總是將CWD更改爲應用程序的安裝目錄? –

+0

順便說一句,當我嘗試'資源:應用程序',我得到一個exeption [例外...]組件返回失敗代碼:0x80004005(NS_ERROR_FAILURE)[nsIProperties.get]「。看來'resource:app'不再被支持。 –

相關問題