Copy link to clipboard
Copied
Hi,
I'm trying to use the File.openWithDefaultApplication() method to open a directory location. I'm running on Windows 7 Professional 64-bit, but have also tested on Windows XP Professional 32-bit with the same result.
The method works fine if I run the app from Flash Builder 4 (either run or debug), but when I try it from a release build it doesn't work. I've exported the release build as a native installer, and I updated the <supportedProfiles> tag in the app's XML to only support "extendedDesktop". That hasn't changed the behavior, however.
Here's an example of how I'm calling the method:
var thedir:File = File.applicationStorageDirectory;
thedir = thedir.resolvePath("the_directory");
if (!thedir.exists)
{
thedir.createDirectory();
}
thedir.openWithDefaultApplication();
Any idea what's going on?
As an aside, if I try to open individual files in the release build, it works fine. So far only opening a directory is a problem. And, I verified the directory exists before trying to open it.
Thanks for any insight you can offer...
Best,
Chris
Hi Chris,
Instead of using openWithDefaultApplication(), try using native process and calling "explorer" on windows, and "open" on mac, then pass the folder path as an argument. Something like this windows example:
private function openWindowsFolder():void { var explorer:File = new File("C:\\Windows\\explorer.exe"); if (explorer.exists) { var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.execut
...Copy link to clipboard
Copied
Hi Chris,
Instead of using openWithDefaultApplication(), try using native process and calling "explorer" on windows, and "open" on mac, then pass the folder path as an argument. Something like this windows example:
private function openWindowsFolder():void { var explorer:File = new File("C:\\Windows\\explorer.exe"); if (explorer.exists) { var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); nativeProcessStartupInfo.executable = explorer; var args:Vector.<String> = new Vector.<String>(); args.push("C:\\Windows"); nativeProcessStartupInfo.arguments = args; process = new NativeProcess(); process.start(nativeProcessStartupInfo); } }
Hope this helps,
Chris
Copy link to clipboard
Copied
Thanks, Chris. That worked!
Best,
Chris
Copy link to clipboard
Copied
What would be the equivalent on a Mac of:
var explorer:File = new File("C:\\Windows\\explorer.exe");
Where is 'open' ?
I realize this is a little old, so thanks in advance if anyone is listening.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now