C#: File Dialog for the Compact Framework
When Microsoft were deciding what to include in the .NET Compact Framework, they decided to restrict the OpenFileDialog and SaveFileDialog to the My Documents directory. There are plenty of reasons you’d need to choose a file outside of My Documents, so I coded a new file chooser from other components.

The dialog is just a form with a ComboBox which shows the current directory and all of it’s parents, a ListView which shows the files and directories in the current directory, and a text box to show the selected file.
Instantiate it with either the default constructor or a directory and file to show on startup.
FileInfo dbFile = new FileInfo("\\Storage Card\\Somefile.txt"); Lime49.OpenFileDialog dlg = new Lime49.OpenFileDialog(dbFile.DirectoryName, dbFile.Name); dlg.Filter = "*.txt"; dlg.ShowDirectory(dbFile.DirectoryName); dlg.ShowDialog(); MessageBox.Show(dlg.SelectedFile);
The selected file is available through the SelectedFile property, and the filter doesn’t work the same way as standard FileDialogs, it uses a standard wildcard pattern to list files.
Download Lime49.OpenFileDialog
Also published on CodeProject

Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks