Hi,

Fabio Serra wrote:
I'm using file.launch() to open a document with the associated application.
I use nsILocalFile and everything works on Windows, but on Linux with KDE
launch() always raise an exception.
Is there a way to open a document with the associated application on Linux KDE?

You can open a document with the associated application on Gnome... It's slightly less straightforward than just .launch() though. This code should work for Windows too, btw:

// yourfile is assumed to be your file
var ms = Components.classes["@mozilla.org/mime;1"]
                   .getService(Components.interfaces.nsIMIMEService);
var type = ms.getTypeFromFile(yourfile);
var mi = ms.getFromTypeAndExtension(type, "");
mi.preferredAction = Components.interfaces.nsIMIMEInfo.useSystemDefault;
mi.launchWithFile(yourfile);



--
All the world's a stage,
And all the men and women merely players:
They have their exits and their entrances;
And one man in his time plays many parts, [...]     --W. Shakespeare
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to