2012-12-12 23 views
2

如何打開XUL的網絡文件夾?我的Firefox工具欄,它可以訪問驅動器像C:,而不是像網絡路徑//Development ...與代碼:file.initWithPath("\\DEVELOPMENT2");如何使用XUL打開網絡文件夾

全碼:

var file = Components.classes["@mozilla.org/file/local;1"] 
     .createInstance(Components.interfaces.nsILocalFile); 

file.initWithPath("\\\DEVELOPMENT2"); //---> this is not working 

//file.initWithPath("Y:"); ---> this is working 

file.reveal(); 

var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess); 
    process.init(file); 

var args = []; 
process.run(false, args, args.length); 

//end 

回答

1

我可以看到兩個問題:

  • 缺少bachslash - 你需要兩個反斜槓,每個反斜槓,總共有四個反斜槓。含義"\\\\DEVELOPMENT2"而不是"\\\DEVELOPMENT2"
  • Firefox無法打開服務器列表 - 它是虛擬位置,而不是實際的文件夾。它可以但是在服務器上打開任何共享文件夾:
var file = Components.classes["@mozilla.org/file/local;1"] 
     .createInstance(Components.interfaces.nsILocalFile); 

file.initWithPath("\\\\DEVELOPMENT2\\folder"); 
file.reveal(); 
+0

非常感謝你,這正是我想要的,乾杯! –

相關問題