|
|||
|
Hi
When using Dialogs.fileOpen, is it possible to choose a default folder to show files from? My program has the following structure: Root folder- .exe program saves folder source images folder When selecting a source image to load, I'd like Dialogs.fileOpen to automatically show that folder. But when saving or opening a saved file, I'd like it to show the saves folder. Is there a way of doing this? |
|
|||
|
By setting the default file, the file open dialog box will go to the folder contains the file. But if the folder does not exist, the fileOpen method will fail. So we do it like this:
Code:
var defaultFile = getAppDir() + "Source Images";
if (Folder.exists(defaultFile))
{
Dialogs.fileOpen("Jpeg images(*.jpg)|*.jpg|",
"jpg", defaultFile + "\\demo.jpg");
}
else
{
Dialogs.fileOpen("Jpeg images(*.jpg)|*.jpg|", "jpg");
}
|
|
|||
|
Thanks for the reply. However, for some reason the Dialogs.fileOpen is not returning a value when contained in the if statement. This is my code
var defaultFile = getAppDir() + "saves"; if (Folder.exists(defaultFile)) { var fileLocation = Dialogs.fileOpen("CCG files(*.ccg)|*.ccg|", ".ccg", defaultFile + "\\example.ccg"); } else { var fileLocation = Dialogs.fileOpen("CCG files(*.ccg)|*.ccg|",".ccg",""); } DataFile.load(fileLocation); fileLocation returns as undefined. However when I try: var fileLocation = Dialogs.fileOpen("CCG files(*.ccg)|*.ccg|",".ccg",""); DataFile.load(fileLocation); or even: var defaultFile = getAppDir() + "saves"; var fileLocation = Dialogs.fileOpen("CCG files(*.ccg)|*.ccg|", ".ccg", defaultFile + "\\example.ccg"); DataFile.load(fileLocation); The correct value is returned. I see no reason for this, maybe you can help. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|