Darin Fisher wrote:
daniel park wrote:

Hello,

I would like to create a temporary file from my XUL application and is there a utility or service that can locate the tmp directory of the filesystem that my application is running on?

thank you,
daniel



var nsIFile = Components.interfaces.nsIFile;
var nsIProperties = Components.interfaces.nsIProperties;

var dirs = Components.classes["@mozilla.org/file/directory_service;1"]
                     .getService(nsIProperties);

var file = dirs.get("TmpD", nsIFile);
file.append("foo.bar");
file.createUnique(nsIFile.NORMAL_FILE_TYPE, 0600);

// file now points at a uniquely named file in the temp directory.


Nice!





Reply via email to