New file and directory open and save dialogs for Windows Mobile

Windows Mobile – like standard Windows – has a default “file open” and a “file save” dialog that all applications can use. If you’re writing an app, you can use it in your code with just a few lines. Great!

Except… no. Because they’re rubbish.

This has come up as an issue raised with a couple of apps that I’ve written that use the standard dialogs. I would defend my apps by saying that I didn’t write the dialogs, and that they’re the same that you get in other Windows Mobile apps like Microsoft Word Mobile. But I can’t, really. For a user, this is just an excuse. Wherever the dialog came from, it is rubbish.

I’ve written a couple of new ones for use in my applications. They’re fairly small, so I’ve made them available if anyone else wants to use them with their apps.

In this post, I’ll quickly outline what is wrong with the standard dialogs, and introduce my new ones.

Windows Mobile file open dialogThe standard Open dialog

Let’s start with the “file open” dialog.

It dumps all of the files from all the directories in one place for you to choose from – with one column in the table used to tell you which folder each file came from.

This means that (as soon as you’ve got a reasonable number of files on your PDA) you get a massive delay when this dialog is opened, while it populates it’s table.

The table ends up with so many things in it that the scroll bar gets really small, and impossible to use without a stylus. Even with the stylus, navigating through all your files in one lump is slow and fiddly.

And worst of all, it only finds files in your root directory, or one directory deep. Any files in subdirectories deeper than this are not included.

|
+--- Directory 1
|      |
|      +--- files here 
|      +--- are included
|
+--- Directory 2
|      |
|      +--- so are these
|
+--- Directory 3
|      |
|      +--- this is accessible
|      |
|      +--- Directory 4
|      |      |
|      |      +--- files here 
|      |      +--- are not 
|      |      +--- included
|      |      |
|      |      +--- Directory 5
|      |             |
|      |             +--- not accessible
|      |

This means that even after you waste your time hunting through a ton of files you aren’t interested in, you find that the files you did want aren’t there.

Which normally means going into “File Explorer”, and moving the file you want to find higher up the directory tree so you can get to it.

Rubbish.

Windows Mobile file save dialogThe standard Save dialog

The save dialog isn’t much better.

Again, your choices for the folder to store a file is limited to “None” (which, confusingly, doesn’t mean save in the root folder – it means save in “My Documents”) or the top level directories in “My Documents” (like “My Pictures”, or “My Music”).

Just don’t choose “My Documents”, because then it saves it in \My Documents\My Documents\

If you want to create a new folder… erm… you can’t. Well – you can start up File Explorer and create it at the top level so it is accessible to the Save dialog.

Argh.

You can see why people were hacked off with my apps… who can blame them?

The new dialogs

new Windows Mobile file dialogThe new dialogs are fairly simple. They come in two flavours – one for files and one for directories.

They let you navigate the folder structure on your device in a traditional file explorer type way.

Each level is only populated when you expand that folder in the tree view – meaning that you don’t have to wait for your PDA to slowly traverse it’s whole filesystem before the dialog is usable.

Apps using these dialogs can set a flag to say whether a user has to pick from existing files / directories, or use the dialog to identify a new file / directory to create.

And they can be called in pretty much the same way as the standard .NET FileDialogs.

FileDialogX dlg = new FileDialogX();
dlg.AllowNewFiles = false;

DialogResult result = dlg.ShowDialog();
if (result == DialogResult.OK)
{
   // filename in:
   //    dlg.FileName;
}

dlg.Dispose();

Simple. But oh, so much more usable!

See it in use

I’ve already added it to my wiki and my notepad apps, and will be adding it to others soon.

If you want a copy for your Windows Mobile app, you can download the DLL for including as a reference in your Visual Studio project, or download the source and make any improvements that you need.

Enjoy!

Tags: , , , , , , , , , ,

Comments are closed.