This documentation is archived and is not being maintained.

FileDialog.Filter Property

Gets or sets the current filename filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box at the bottom of a file dialog.

Namespace: Microsoft.Win32
Assembly: PresentationFramework (in presentationframework.dll)

public string Filter { get; set; }
/** @property */
public String get_Filter ()

/** @property */
public void set_Filter (String value)

public function get Filter () : String

public function set Filter (value : String)

<object Filter="string" .../>

Property Value

A String that contains the filter. The default is Empty.

Exception typeCondition

ArgumentException

if the filter string is invalid.

This string has a particular compact syntax to describe combinations of filters.

  • The vertical bar character | is used to separate the label shown to users in the "Save as file type" options from the practical meaning of each filter.

  • The label is the characters are displayed literally as part of the "Save as file type" or "Files of type" options presented to the user. It is common to give such options friendly names followed by a string that contains the extensions and wildcards, separated by semicolons, that equate to the file types represented by the friendly name.

  • The practical meaning declares how the filters are applied. Here, the wildcard character * is a wildcard as used by the filter for one or both sides of the . ordinal. Semicolons are used to separate filters that are additive under the same option. Filters without wildcards are appropriate in some circumstances.

  • The vertical bar character | is also used to separate different filtering combinations that are presented to the user. Each additional combination is expected to be a label | meaning.

  • It is always expected that there is at least one filter option. If this string is left empty, the default of | *.* (unlabeled filter, practical meaning of *.*) is applied.

The following is an example filter string:

Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: