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!

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:

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

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.