Skip to main content
Participating Frequently
November 24, 2010
Answered

File.openWithDefaultApplication() to open directory not working from release build

  • November 24, 2010
  • 1 reply
  • 2519 views

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

This topic has been closed for replies.
Correct answer chris.campbell

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

1 reply

chris.campbell
chris.campbellCorrect answer
Legend
December 1, 2010

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

cwilson03Author
Participating Frequently
December 6, 2010

Thanks, Chris.  That worked!

Best,

Chris