Save Folder Dialog?

Is it possible to create (save) a folder/directory with something like a SaveFileDialog object?
I would like for a user to be able to create a new, empty directory in a location they specify, and I would also like to provide a suggested folder name (as can be done with SaveFileDialog).
~
Thanks!

https://documentation.xojo.com/api/files/folderitem.html.ShowSelectFolderDialog

At the page bottom, read See Also to get related stuff.

Thank you for responding @Emile_Schwarz.

However I donā€™t see how it allows me to have the behavior outlined in my original post.

Am I overlooking something?
~
Thanks

So, you want to create a Folder without dialog ?

Read FolderItem in the LR:
https://documentation.xojo.com/api/files/folderitem.html

Who specify the location ? You in the software or the user ?

In the former, the answer depends on where you want to create that folder: in Documents ? in Application Data ?

Use SpecialFolder (link found in FolderItem See Also).

If the later, you already have the answer.

To get more precise answer (if the above is not enough), be more specific in your question.

In short:
you have to set a valid FolderItem, then you can use f.CreateFolder (proper syntax to use in the LR) to create a folder without the user.

No. I can create folders without a dialog without issue.

I was wondering if there was an existing dialog (or if it was possible to configure an existing dialog) to allow a user to create a directory/folder in the same way I can have the user save a file.

Doesnā€™t suit your needs to show a save dialog (the exact same dialog as when you want to save a file: the user chooses the location and name) and, later, instead of saving as a file, you create a folder of the chosen item in the dialog?
Just donā€™t specify an extension as the filter.

And searching the LR instead of wandering ?
As far as I know, there is no hidden instructions in Xojo :wink:

All appears in the Language Reference.

BTW: dd you look at ShowSelectFolderDialog ?
It allow the user to Select a Folder OR create a New Folder an Select it. Looks like what you want.

Yes, of course.
However I often get ideas and advice from others here ā€“ or even learn of things that I have missed in my research.

I donā€™t agree.
There is lots of information in the Language Reference but not always solutionsā€¦ or ideas of how to apply that information.

Yes. It almost does what I wantā€¦ but not quite.
Itā€™s possible that I can find a way to make it work for me though.

And what about my idea?

@Arnaud_N, I really like that idea.
It didnā€™t occur to me to take the results returned from the Save File dialog and do something else with them.

I ended up creating a window to do what need to do (including folder name validation, creating required subfolders, etc.)

That having been said, I think I will implement your suggestion and see if that ends up being a cleaner solution. (The only thing I can think of that might not be ideal is that I donā€™t think I can perform the name validation.)

Thanks!

Be aware that making your own ā€œnavigation dialogā€ may be bad from the userā€™s point of view. Thereā€™s a lot involved in them (keyboard shortcuts, drag&drop of a folder to the dialog to show its content, the OS handling all it knows (e.g. packages shown as ā€œfilesā€), visual location of items and roles, handling new and removed files, etc (a lot of things, in fact).). Users have habits and expectations. Also, you may be aware of the Human Interface Guidelines, where recommendations are published to make apps.

Personally, and I know itā€™s far from being only me, when I see a custom navigation dialog (like you used to see in Java applications) or known piece of dialogs/UI items that have been built and customised, I start to not trust the app anymore until I see a lot of flaws in them.

Do you have reserved names or a set of names allowed? How many?

There are ways to (1) add controls to a save/select folder dialog or (2) handle events of such dialogs, like, as you want, preventing the dialog to close if somethingā€™s ā€œwrongā€ (like an invalid name entered) and even more. But those are specific, thus Xojo doesnā€™t provide them directly (youā€™ll have to use the MBS plugin or declares).

You do know that on the SaveFile dialog, there is a ā€˜New Folderā€™ button?

And that allows

ā€˜a user to be able to create a new, empty directory in a location they specifyā€™

(You wouldnt suggest a new folder name, of course.)
Just show a SaveFile dialog and ask the user to save a ā€˜settings fileā€™ anywhere they like.
If they create a folder at the same time, no problem. Create your dummy file in the location they choose.

1 Like

@Arnaud_N:
All very good points. I generally feel the same way when I see home brewed interface elements.
In this case, however, Iā€™m building a tool that is very specific in itā€™s function(s) and will only be used by my team ā€“ no more than 5 people. Since it is so specialized and has such a small (and tight knit) user base I think it makes sense to implement a custom dialog in this case.

@Jeff_Tullin:
Yes, I am aware of the option to create a new directory from within built in save dialogs, thanks.
What Iā€™m actually doing is having the user select a location for a specifically named set of nested folders to be used for subsequent processes. Again, to be used by a small number of people who are very familiar with the toolā€™s function.

small number of people who are very familiar with the toolā€™s function.
You may fall into the other trap:

your persons may be surprised by what we feel is standard (normal) ways if your application takes some liberties with them :wink:

Now, this is your software / your people. You can train them in a way or another. Your responsability.

Ah yes, I guess it makes sense.
Anyway, take into account the keyboard shortcuts (etc) your 5 people might be accustomed to :wink:; if they are ā€œadvancedā€ users, they probably have their habits, and those make workflows more dynamic. Perhaps ask them what theyā€™d want.

This is good, unless all you want is just create a folder (i.e. you then have to cancel the main dialog, which isnā€™t a full ā€œcancelā€ (weird design, then)).

Iā€™m then assuming (1) you already know the root folderā€™s name (itā€™s a fixed name) and (2) the folder you want your user(s) to create (which encloses the one with a fixed name) can be freely named, correct?
If true, then showing a regular SaveAsDialog would work, despite its name, where you can create the folder returned by the dialog. This also has the benefit that, if an item with this name already exists, the OS will ask the user whether to replace the file.
But it depends on whether (1) and (2) are correct assumptionsā€¦ :thinking:

Well, yes.
My custom dialog first calls an SelectFolderDialog to determine the location for the folder being created, if it hasnā€™t already been determined from prior operations.

Hence asking someone to save a dummy ā€˜Settings fileā€™
if they know they are saving a file, you can call it settings.txt
And once you have the file location, the (possibly new) folder is its parent