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

설명

확장 문자열에는 선행 마침표가 포함되어야 합니다. 예를 들어 속성을 ".txt"로 설정 DefaultExt 하여 모든 텍스트 파일을 선택합니다.

기본적으로 속성에서 AddExtension 표시 된 파일 목록을 Filter 필터링 하는 확장을 확인 하려고 합니다 속성입니다. 확장에서 확인할 수 없는 경우는 Filter 속성 DefaultExt 대신 사용 됩니다.

적용 대상