Skip to main content
4everJang
Legend
August 15, 2014
Question

ChooseFile not working to open a directory ?

  • August 15, 2014
  • 3 replies
  • 672 views

Hi all,

I am creating an installer for my scripts and need to get an istall directory from the customer. It seems that ChooseFile ( ) with the ChooseOpenDir parameter is exactly what I need. But this does not work: there is no dialog and the return value is always null. Does anyone else experience this? Is this a bug in FM or just something wrong in my FM installation? I am running FM 12.0.0.308 on Windows 7.

Ciao

Jang

This topic has been closed for replies.

3 replies

Legend
August 15, 2014

Hi Jang,

It works for me, something like this:

var path = ChooseFile("Browse for folder", "", "", Constants.FV_ChooseOpenDir);

alert(path);

One thing though... there is a bug in the interface where the prompt will fail and just return null if the start path is bogus:

var path = ChooseFile("Browse for folder", "C:\\Some\\Bogus\\Path", "", Constants.FV_ChooseOpenDir);

Make sure that the path is a valid folder, if you are specifying one. It might even give you problems if the path points to a file, even if valid.

Russ

Inspiring
August 15, 2014

Jang,

I always use openDlg function of Folder class. This works well for my use cases.

I think I discovered the same issue former times and decided to use Folder class.

Hope this helps

Markus

BTW: I wrote and extend script installer some time ago. practice innovation | SWATFMINSTALLSCRIPTS

frameexpert
Community Expert
Community Expert
August 15, 2014

Hi Jang,

Post your code and I will try it here. Or, you could ExtendScript's built-in Folder methods:

var folder = Folder(app.OpenDir).selectDlg ("Select a folder:");

or

var folder = Folder.selectDialog ("Select a folder:");

The major difference is that selectDlg lets you start with a default folder selected.

Rick

www.frameexpert.com