Mon, December 17, 2007, 04:32 AM under
dotNET
In Windows Forms, the
OpenFileDialog and
SaveFileDialog inherit from the abstract
FileDialog class. If you work with these classes you should know that there have been a few additions in this area as highlighted by the following class diagram.
There are broadly 3 enhancements:
1. The OpenFileDialog has a new property (
SafeFileName) that returns just the name and extension of the selected file without the path information. Because of that it is accessible to applications running with limited trust. Should the selected files be more than one, you can use the corresponding
SafeFileNames property that returns an array of strings.
2. There is a new property for both
Save- and
OpenFileDialog that is only applicable on Windows Vista (it gets ignored on XP):
AutoUpgradeEnabled. The default is true, and it means that the dialogs will have the Vista look and feel when run on Vista.
3. If you have not opted out from auto upgrading for Vista just discussed, then another property of the 2 dialogs may be useful:
CustomPlaces (of type
FileDialogCustomPlacesCollection). You can use this to add strings (or
Known Folder GUIDs) that represent locations on your disc that are then easily accessible to the user of the dialog you are showing via the "Favorite Links" section.
To see the Vista dialog in action with custom places,
watch my screencast.