FileDialog.DefaultExt プロパティ

定義

表示されるファイル リストにフィルターを適用するための既定の拡張子文字列を指定する値を取得または設定します。

public:
 property System::String ^ DefaultExt { System::String ^ get(); void set(System::String ^ value); };
public string DefaultExt { get; set; }
member this.DefaultExt : string with get, set
Public Property DefaultExt As String

プロパティ値

既定の拡張子文字列。 既定値は、Empty です。

次の例は、既定のファイル名と拡張子の種類を含む を OpenFileDialog 作成する方法を示しています。

// Configure open file dialog box
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();

// Process open file dialog box results
if (result == true)
{
    // Open document
    string filename = dlg.FileName;
}
' Configure open file dialog box
Dim dlg As New Microsoft.Win32.OpenFileDialog()
dlg.FileName = "Document" ' Default file name
dlg.DefaultExt = ".txt" ' Default file extension
dlg.Filter = "Text documents (.txt)|*.txt" ' Filter files by extension

' Show open file dialog box
Dim result? As Boolean = dlg.ShowDialog()

' Process open file dialog box results
If result = True Then
    ' Open document
    Dim filename As String = dlg.FileName
End If

注釈

拡張文字列には、先頭のピリオドが含まれている必要があります。 たとえば、 プロパティを DefaultExt ".txt" に設定して、すべてのテキスト ファイルを選択します。

既定では、 プロパティは AddExtension 、表示されるファイルリストをプロパティからフィルター処理する拡張機能を Filter 決定しようとします。 プロパティから拡張機能を Filter 特定できない場合は、 DefaultExt が代わりに使用されます。

適用対象