This documentation is archived and is not being maintained.

OpenFileDialog.Multiselect Property

Gets or sets a value indicating whether the dialog box allows multiple files to be selected.

[Visual Basic]
Public Property Multiselect As Boolean
[C#]
public bool Multiselect {get; set;}
[C++]
public: __property bool get_Multiselect();
public: __property void set_Multiselect(bool);
[JScript]
public function get Multiselect() : Boolean;
public function set Multiselect(Boolean);

Property Value

true if the dialog box allows multiple files to be selected together or concurrently; otherwise, false. The default value is false.

Remarks

Use FileNames to access the full list of selected file names.

There is a hard-coded limit of 200 files that can be opened with the Open File dialog box. For more information about this limitation, see article 820631, "PRB: 'Too Many Files Selected' Error Message Occurs When You Use the OpenFileDialog Control", in the Microsoft Knowledge Base at http://support.microsoft.com.

Example

The following code example demonstrates initializing an OpenFileDialog object, setting the Title and Filter properties, and allowing the user to select multiple files by setting the System.Windows.Forms.OpenFileDialog.MultiSelect property to true. To run this example paste the following code in a form containing an OpenFileDialog named OpenFileDialog1 and a Button named fileButton. Call the InitializeOpenFileDialog method in the form's constructor or Load method. The example also assumes that the Click event of the Button control is connected to the event handling method defined in the example.

[SampleID='System.Windows.Forms.FileDialog' SnippetID='6']
--------- Languages displayed= cs, vb ---------
--------- cs ---------
--------- Snippet 6 ---------
    private void InitializeOpenFileDialog()
    {
        this.OpenFileDialog1 = new System.Windows.Forms.OpenFileDialog();
        // Set the file dialog to filter for graphics files.
        this.OpenFileDialog1.Filter = 
            "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" + 
            "All files (*.*)|*.*";
        // Allow the user to select multiple images.
        this.OpenFileDialog1.Multiselect = true;
        this.OpenFileDialog1.Title = "My Image Browser";
        
    }
    private void fileButton_Click(System.Object sender, System.EventArgs e)
    {
        OpenFileDialog1.ShowDialog();
    }
--------- vb ---------
--------- Snippet 6 ---------
    Private Sub InitializeOpenFileDialog()
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        ' Set the file dialog to filter for graphics files.
        Me.OpenFileDialog1.Filter = _
        "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"
        ' Allow the user to select multiple images.
        Me.OpenFileDialog1.Multiselect = True
        Me.OpenFileDialog1.Title = "My Image Browser"
    End Sub
    Private Sub fileButton_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles FileButton.Click
        OpenFileDialog1.ShowDialog()
   End Sub

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OpenFileDialog Class | OpenFileDialog Members | System.Windows.Forms Namespace | FileNames

Show: