FileDialog.DefaultExt プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
表示されるファイルの一覧をフィルター処理するために使用する既定の拡張文字列を指定する値を取得または設定します。
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.Value)
{
// 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が使用されます。