{"id":212,"date":"2007-11-20T20:53:39","date_gmt":"2007-11-20T20:53:39","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=212"},"modified":"2007-11-20T20:54:26","modified_gmt":"2007-11-20T20:54:26","slug":"new-file-and-directory-open-and-save-dialogs-for-windows-mobile","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=212","title":{"rendered":"New file and directory open and save dialogs for Windows Mobile"},"content":{"rendered":"<p>Windows Mobile &#8211; like standard Windows &#8211; has a default &#8220;file open&#8221; and a &#8220;file save&#8221; dialog that all applications can use. If you&#8217;re writing an app, you can use it in your code with just a few lines. Great!<\/p>\n<p>Except&#8230; no. Because they&#8217;re rubbish. <\/p>\n<p>This has come up as <a href=\"http:\/\/icanhaz.com\/bladewiki\" target=\"_blank\">an issue raised<\/a> with a couple of apps that I&#8217;ve written that use the  standard dialogs. I would defend my apps by saying that I didn&#8217;t write the dialogs, and that they&#8217;re the same that you get in other Windows Mobile apps like Microsoft Word Mobile. But I can&#8217;t, really. For a user, this is just an excuse. Wherever the dialog came from, it is rubbish.<\/p>\n<p>I&#8217;ve written a couple of new ones for use in my applications. They&#8217;re fairly small, so <a target=\"_blank\" href=\"http:\/\/code.google.com\/p\/windowsmobilefiledialogs\/\">I&#8217;ve made them available<\/a> if anyone else wants to use them with their apps. <\/p>\n<p>In this post, I&#8217;ll quickly outline what is wrong with the standard dialogs, and introduce my new ones. <\/p>\n<p><!--more--><img decoding=\"async\" src=\"post-images\/071120-existing-open.jpg\" alt=\"Windows Mobile file open dialog\" align=\"left\" hspace=\"10\" vspace=\"5\"\/><strong>The standard Open dialog<\/strong><\/p>\n<p>Let&#8217;s start with the &#8220;file open&#8221; dialog. <\/p>\n<p>It dumps all of the files from all the directories in one place for you to choose from &#8211; with one column in the table used to tell you which folder each file came from. <\/p>\n<p>This means that (as soon as you&#8217;ve got a reasonable number of files on your PDA) you get a massive delay when this dialog is opened, while it populates it&#8217;s table. <\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<pre><code>|\r\n+--- Directory 1\r\n|      |\r\n|      +--- files here \r\n|      +--- are included\r\n|\r\n+--- Directory 2\r\n|      |\r\n|      +--- so are these\r\n|\r\n+--- Directory 3\r\n|      |\r\n|      +--- this is accessible\r\n|      |\r\n|      +--- Directory 4\r\n|      |      |\r\n|      |      +--- files here \r\n|      |      +--- are not \r\n|      |      +--- included\r\n|      |      |\r\n|      |      +--- Directory 5\r\n|      |             |\r\n|      |             +--- not accessible\r\n|      |<\/code><\/pre>\n<p>This means that even after you waste your time hunting through a ton of files you aren&#8217;t interested in, you find that the files you did want aren&#8217;t there.<\/p>\n<p>Which normally means going into &#8220;File Explorer&#8221;, and moving the file you want to find higher up the directory tree so you can get to it.<\/p>\n<p>Rubbish.<\/p>\n<p><img decoding=\"async\" src=\"post-images\/071120-existing-save.jpg\" alt=\"Windows Mobile file save dialog\" align=\"right\" hspace=\"10\" vspace=\"5\"\/><strong>The standard Save dialog<\/strong><\/p>\n<p>The save dialog isn&#8217;t much better. <\/p>\n<p>Again, your choices for the folder to store a file is limited to &#8220;None&#8221; (<em>which, confusingly, doesn&#8217;t mean save in the root folder &#8211; it means save in &#8220;My Documents&#8221;<\/em>) or the top level directories in &#8220;My Documents&#8221; (like &#8220;My Pictures&#8221;, or &#8220;My Music&#8221;). <\/p>\n<p>Just don&#8217;t choose &#8220;My Documents&#8221;, because then it saves it in <code>\\My Documents\\My Documents\\<\/code><\/p>\n<p>If you want to create a new folder&#8230; erm&#8230; you can&#8217;t. Well &#8211; you can start up File Explorer and create it at the top level so it is accessible to the Save dialog.<\/p>\n<p>Argh. <\/p>\n<p>You can see why people were hacked off with my apps&#8230; who can blame them?<\/p>\n<p><strong>The new dialogs<\/strong><\/p>\n<p><img decoding=\"async\" src=\"post-images\/071120-file.jpg\" alt=\"new Windows Mobile file dialog\" align=\"left\" hspace=\"10\" vspace=\"5\"\/>The new dialogs are fairly simple. They come in two flavours &#8211; one for files and one for directories. <\/p>\n<p>They let you navigate the folder structure on your device in a traditional file explorer type way. <\/p>\n<p>Each level is only populated when you expand that folder in the tree view &#8211; meaning that you don&#8217;t have to wait for your PDA to slowly traverse it&#8217;s whole filesystem before the dialog is usable. <\/p>\n<p>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.<\/p>\n<p>And they can be called in pretty much the same way as the standard .NET FileDialogs. <\/p>\n<pre><code>FileDialogX dlg = new FileDialogX();\r\ndlg.AllowNewFiles = false;\r\n\r\nDialogResult result = dlg.ShowDialog();\r\nif (result == DialogResult.OK)\r\n{\r\n   \/\/ filename in:\r\n   \/\/    dlg.FileName;\r\n}\r\n\r\ndlg.Dispose();<\/code><\/pre>\n<p>Simple. But oh, so much more usable!<\/p>\n<p><strong>See it in use<\/strong><\/p>\n<p>I&#8217;ve already added it to my <a href=\"http:\/\/dale.lane.googlepages.com\/\" target=\"_blank\">wiki<\/a> and my <a href=\"http:\/\/dalelane.co.uk\/page.php?id=40\" target=\"_blank\">notepad<\/a> apps, and will be adding it to others soon.<\/p>\n<p>If you want a copy for your Windows Mobile app, you can <a href=\"http:\/\/code.google.com\/p\/windowsmobilefiledialogs\/\">download the DLL<\/a> for including as a reference in your Visual Studio project, or <a href=\"http:\/\/code.google.com\/p\/windowsmobilefiledialogs\/\">download the source<\/a> and make any improvements that you need.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Mobile &#8211; like standard Windows &#8211; has a default &#8220;file open&#8221; and a &#8220;file save&#8221; dialog that all applications can use. If you&#8217;re writing an app, you can use it in your code with just a few lines. Great! Except&#8230; no. Because they&#8217;re rubbish. This has come up as an issue raised with a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[20,33,571,31,29,21,28,32,30,22,19],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-code","tag-net","tag-netcf","tag-code","tag-dialog","tag-directory","tag-dotnet","tag-file","tag-forms","tag-save","tag-visual-studio","tag-windows-mobile"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}