OpenFileDialog Component Overview (Windows Forms)
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

OpenFileDialog Component Overview (Windows Forms) 

The Windows Forms OpenFileDialog component is a pre-configured dialog box. It is the same Open File dialog box exposed by the Windows operating system. It inherits from the CommonDialog class.

Use this component within your Windows-based application as a simple solution for file selection in lieu of configuring your own dialog box. By relying on standard Windows dialog boxes, you create applications whose basic functionality is immediately familiar to users. Be aware, however, that when using the OpenFileDialog component, you must write your own file-opening logic.

Use the ShowDialog method to display the dialog at run time. You can enable users to multi-select files to be opened with the Multiselect property. Additionally, you can use the ShowReadOnly property to determine if a read-only check box appears in the dialog box. The ReadOnlyChecked property indicates whether the read-only check box is selected. Finally, the Filter property sets the current file name filter string, which determines the choices that appear in the "Files of type" box in the dialog box.

When it is added to a form, the OpenFileDialog component appears in the tray at the bottom of the Windows Forms Designer.

© 2015 Microsoft