mangovn
mangovn

Reputation: 394

How to set default file browse location with firefox addon sdk

Im new Firefox addon programming. I want set default file browse location with firefox addon sdk. Thank you so much.

Upvotes: 0

Views: 751

Answers (1)

Noitidart
Noitidart

Reputation: 37238

open scratchpad copy and paste this:

const nsIFilePicker = Components.interfaces.nsIFilePicker;

var fp = Components.classes["@mozilla.org/filepicker;1"]
               .createInstance(nsIFilePicker);
var startDir = FileUtils.File('C:\\');
fp.displayDirectory = startDir;

fp.init(window, "Dialog Title", nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);

var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
  var file = fp.file;
  // Get the path as string. Note that you usually won't 
  // need to work with the string paths.
  var path = fp.file.path;
  // work with returned nsILocalFile...
}

if thats what you want let me know, then ill put it in a default location

Upvotes: 2

Related Questions