Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: Not mapped to an xmlns.
If is either null or Empty, all files are displayed, and folders are always displayed.
You can specify a subset of file types to be displayed by setting the property. Each file type can represent a specific type of file, such as the following:
Word Documents (*.doc)
Excel Worksheets (*.xls)
PowerPoint Presentations (*.ppt)
Alternatively, a file type can represent a group of related file types, such as the following:
Office Files (*.doc, *.xls, *.ppt)
All Files (*.*)
To specify a subset of the types of files that are displayed, you set the property with a string value (the filter string) that specifies one or more types of files to filter by. The following shows the expected format of the filter string:
You use the following format to describe each file type:
The Label part is a human-readable string value that describes the file type, such as the following:
Each file type must be described by at least one Extension. If more than one Extension is used, each Extension must be separated by a semicolon (";"). For example:
The following are complete examples of valid string values:
Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt|Office Files|*.doc;*.xls;*.ppt|All Files|*.*
The user can choose a file type from this list to filter by. By default, the first item in the list (for example, the first file type) is selected when the OpenFileDialog or SaveFileDialog is displayed. To specify that another file type to be selected, you set the FilterIndex property before showing the OpenFileDialog or SaveFileDialog (by calling ShowDialog).
The following examples demonstrate several types of filter strings that can be set by using the property.
using Microsoft.Win32; ... OpenFileDialog dlg = new OpenFileDialog(); // Filter by Word Documents OR Excel Worksheets OR PowerPoint Presentations // OR Office Files // OR All Files dlg.Filter = "Word Documents|*.doc|Excel Worksheets|*.xls|PowerPoint Presentations|*.ppt" + "|Office Files|*.doc;*.xls;*.ppt" + "|All Files|*.*"; dlg.ShowDialog();
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.