[Project_owners] Opening files

Neil neil at parkwaycc.co.uk
Wed Jul 26 13:21:03 EDT 2006


Michael Buckley wrote:

> The first is how to select the path that the open file dialog opens 
> with?  What I am using looks like this.
>
> openFileNow: function(){
>    var openPath = 
> Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch) 
>
>        .getCharPref('extension.editor.folder.openSave')
>    var openX = gStrings.getString('openX');
>    const nsIFilePicker = Components.interfaces.nsIFilePicker;
>    var fp =
> Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker); 
>
>    fp.init(window, openX, nsIFilePicker.modeOpen);
>    fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);

fp.displayDirectory = 
Components.classes['@mozilla.org/preferences-service;1']
    .getService(Components.interfaces.nsIPrefBranch)
    .getComplexValue('extension.editor.folder.openSave', 
Components.interfaces.nsILocalFile);

Naturally you should ensure that an nsILocalFile pref exists or do some 
error checking ;-)


More information about the Project_owners mailing list