function checkFile(testfile) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { //alert("Permission to read file was denied.");
} var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile);
if (!testfile) return; file.initWithPath(testfile); if (file.exists() && file.isDirectory()) return true; else return false; }
|
更多详细接口可以参考:
http://developer.mozilla.org/en/docs/nsILocalFile
另外还有个写文件的例子:
阅读(1050) | 评论(0) | 转发(0) |