[Project_owners] How to set the displayDirectory in a nsIFilePicker

Didier Ernotte didier at ernotte.com
Fri Dec 16 11:33:08 EST 2005


Hi,

I want to open a nsIFilePicker in the FF profile directory. I have read
that the displayDirectory attribute should do this, but I can't make it
work. The FilePicker opens, but in a totally different directory.

Here is my code

    var dir =
Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD",
Components.interfaces.nsILocalFile);
    var filePicker =
Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);
    filePicker.displayDirectory = dir;
    filePicker.init(window, "Hello",
Components.interfaces.nsIFilePicker.modeOpen);
    filePicker.defaultString = null;
    filePicker.appendFilters(filePicker.filterAll);

    filePicker.show();


Thanks

Didier


More information about the Project_owners mailing list