Christian Biesinger wrote:
 > // 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);

Thanks Christian. I tried with KDE but it doesn't work.

[Exception... "Component returned failure code: 0x80520012
(NS_ERROR_FILE_NOT_FOUND) [nsIMIMEInfo.launchWithFile]"  nsresult:
"0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame ::
chrome://idealw3/content/js/main.js :: openDoc :: line 267"  data: no]

The strange thing is that if I try to open the file with a simple
window.location = "file://" + filePath in the open/save dialog window
the default application is correctly selected. So Firefox somewhere know
how can handle the file.
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to