From MozillaZine Knowledge Base

(Difference between revisions)
Revision as of 00:19, 6 March 2005
Asqueella (Talk | contribs)
<-- Previous diff
Revision as of 02:13, 26 March 2005
Fatalis (Talk | contribs)

Next diff -->
Line 28: Line 28:
{{msg:stub}} {{msg:stub}}
-[[Category:Example code|nsIFilePicker]] [[Category:XPCOM example code|nsIFilePicker]] [[Category:Javascript example code|nsIFilePicker]]+[[Category:Example code|nsIFilePicker]] [[Category:XPCOM example code|nsIFilePicker]] [[Category:JavaScript example code|nsIFilePicker]]

Revision as of 02:13, 26 March 2005

This page is part of the extension development documentation project.

Ask your questions in MozillaZine Forums. Also try browsing example code.

Note: development documentation is in process of being moved to Mozilla Development Center (MDC).

Using nsIFilePicker

const nsIFilePicker = Components.interfaces.nsIFilePicker;

var fp = Components.classes[";1"]
fp.init(window, "Dialog Title", nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);

var rv =;
if (rv == nsIFilePicker.returnOK)
  var file = fp.file;
  // work with returned nsILocalFile...


  • If you pass empty string as dialog title, the dialog will have default title
  • When checking return value for Save dialog, be sure to check for nsIFilePicker.returnReplace too.
  • Available modes: modeOpen, modeSave, modeGetFolder, modeOpenMultiple.
  • Available filters: filterAll, filterHTML, filterText, filterImages, filterXML, filterXUL, filterApps.