Bug or feature: OpenFileDialog can select a folder

I have a user who isn’t really computer savvy and then makes interesting problems. He created a folder with the name “Mail Archiver.vdb” and then put a file with the same name into the folder.

An OpenFileDialog with the extension vdb like this:

dim theDialog as new OpenFileDialog
Dim DBType As New FileType
dbType.Name = "vdb"
dbType.Extensions = "vdb"
theDialog.Filter = DBType
theDialog.PromptText = kSelectArchive
Return theDialog.showModal

can now not only select a file with the ending vdb but also the parent folder. Is this a bug or not? How can I prevent the selection of a folder?

I’m not sure you can keep users from doing dumb stuff, but if nothing else you can add a test of the folder item you get back and if not what you can process, then put up a dialog to tell them and make them try again.

The “fun” thing is that users are so creative and keep coming up with scenarios we would never had thought to safeguard against.


That’s one hella creative user you’ve got there :))


The FileOpenDialog from the MBS plugin has an option to disallow folders. For now I’ll just add a check for the most important file dialog. I still think that this is a bug.

1 Like

In no way it is a bug, folders CAN have “extensions” ( dot-whatever at the end ). So it is your duty to check if what the user sent to you is valid before proceeding. And a FolderItem.Exists and FolderItem.IsFolder are very basic checks everyone does all the time. Sometimes we check even the content (size, few signature bytes, etc). I also have some users that I have no proper adjectives to describe them.

1 Like

The dialog has the name “SelectFileDialog” in contrast to “SelectFolderDialog” which selects a folder and not a file. On macOS there is only a FileOpenPanel where you can select both.


Apple complicates this by making folders appear as files in the case of bundles.

If you use my macOS dialogs classes, you can specify the uniform type identifiers and specifically exclude folders.


[quote=“Rick Araujo, post:5, topic:78609, username:Rick_Araujo”]
In no way it is a bug, folders CAN have “extensions” ( dot-whatever at the end ). [/quote]

I think you are wrong. That is thinking at the wrong level of abstraction IMO.

What If your app needs a file selected (but you can’t exactly specify the file type- rare but not unheard of)?

Having “.whatever” at the end of a folder name does not make it a file.

A basic principle of good UI IMO is not giving users inappropriate options…

Even if you check for it then you have to popup a messing telling the user what they did wrong so they won’t be confused… Not a great user experience.

Not giving users the chance of making (or even seeing) nonsensensical or inacessable choices IMO makes the UI more intuitive and the overall user experience better IMO.


1 Like

Maybe here lies the source of the problem, Mac/Windows/Linux being reduced to the common parts, and in some of them they simply can’t handle it in the desired way, so all them have the minimal common sets.

It’s not thinking at levels of abstraction, it is showing a reality, and one way to handle it.