private void Button_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofdlg = new Microsoft.Win32.OpenFileDialog(); { // 다이얼로그의 좌측 즐겨찾기(?) 에 바로가기가 표시된다. ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Contacts); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Cookies); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Desktop); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Documents); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Favorites); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.LocalApplicationData); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Music); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Pictures); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.ProgramFiles); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.ProgramFilesCommon); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Programs); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.RoamingApplicationData); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.SendTo); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.StartMenu); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Startup); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.System); ofdlg.CustomPlaces.Add(FileDialogCustomPlaces.Templates); // 바로가기 위치 생성도 가능하다. Microsoft.Win32.FileDialogCustomPlace myPlace = new Microsoft.Win32.FileDialogCustomPlace(@"C:\driver"); ofdlg.CustomPlaces.Add(myPlace); ofdlg.InitialDirectory = @"C:\driver"; // 기본 폴더 지정 ofdlg.CheckFileExists = true; // 파일 존재여부확인 ofdlg.CheckPathExists = true; // 폴더 존재여부확인 ofdlg.Filter = // 필터설정 (주로 확장자 및 주요 파일을 필터로 설정함) "Zip 파일 | *.zip; *.rar"; //// 파일 선택 완료 시 이벤트 //ofdlg.FileOk += (s, a) => //{ // System.Windows.MessageBox.Show("Completed"); //}; // 파일 열기 (값의 유무 확인) if (ofdlg.ShowDialog().GetValueOrDefault()) { addr.Text = ofdlg.FileName; path = addr.Text; System.Windows.MessageBox.Show(path); } } }
private static IShellItem ResolveCustomPlace(FileDialogCustomPlace customPlace) { // Use the KnownFolder Guid if it exists. Otherwise use the Path. return ShellUtil.GetShellItemForPath(ShellUtil.GetPathForKnownFolder(customPlace.KnownFolder) ?? customPlace.Path); }
private static IShellItem ResolveCustomPlace(FileDialogCustomPlace customPlace) { return(ShellUtil.GetShellItemForPath(ShellUtil.GetPathForKnownFolder(customPlace.KnownFolder) ?? customPlace.Path)); }