OpenFileDialog
Prompts the user to open a file from the server.
Last updated
Was this helpful?
Prompts the user to open a file from the server.
Last updated
Was this helpful?
This class allows you to check whether a file exists and to open it. The ShowReadOnly
property determines whether a read-only check box appears in the dialog box. The ReadOnlyChecked
property indicates whether the read-only check box is checked.
Most of the core functionality for this class is found in the FileDialog
class.
If you want to give the user the ability to select a folder instead of a file, use FolderBrowserDialog instead.
For a full list of properties, methods and events see the API documentation.
The OpenFileDialog filters files shown to the user based on a given pattern. For example, the filter C# files|*.cs|All files|*.*
will show files ending with .cs by default. Users can modify the filter using the dropdown menu.
The FileDialog.FileName property returns the virtual path relative to the root. To get the physical path on the server, use FileDialog.MapPath().
The OpenFileDialog includes an optional "?" (Help) tool for displaying navigation assistance.
Add at least one IFileSystemProvider
to the Roots collection before showing the dialog:
The OpenFileDialog supports customization of individual controls including textboxes and pickers.
To customize these controls:
Create a class inheriting from FileDialogUI
Add the custom OpenFileDialog
constructor
Modify the controls as needed
After applying the OpenFileDialog's DialogTemplate
property to the new class, the result looks like this:
For advanced customization of the OpenFileDialog
using custom templates, see below.