internal virtual void OnBeforeVistaDialog(FileDialogNative.IFileDialog dialog) { dialog.SetDefaultExtension(this.DefaultExt); dialog.SetFileName(this.FileName); if (!string.IsNullOrEmpty(this.InitialDirectory)) { try { FileDialogNative.IShellItem initialDirectory = GetShellItemForPath(this.InitialDirectory); dialog.SetDefaultFolder(initialDirectory); dialog.SetFolder(initialDirectory); } catch (FileNotFoundException) { } } dialog.SetTitle(this.Title); dialog.SetOptions(GetOptions()); SetFileTypes(dialog); this._customPlaces.Apply(dialog); }
private void SetDialogProperties(FileDialogNative.IFileDialog dialog) { // Description if (!string.IsNullOrEmpty(descriptionText)) { if (UseDescriptionForTitle) { dialog.SetTitle(descriptionText); } else { FileDialogNative.IFileDialogCustomize customize = (FileDialogNative.IFileDialogCustomize)dialog; customize.AddText(0, descriptionText); } } dialog.SetOptions(FileDialogNative.FOS.FOS_PICKFOLDERS | FileDialogNative.FOS.FOS_FORCEFILESYSTEM | FileDialogNative.FOS.FOS_FILEMUSTEXIST); if (!string.IsNullOrEmpty(selectedPath)) { string parent = Path.GetDirectoryName(selectedPath); if (parent == null || !Directory.Exists(parent)) { dialog.SetFileName(selectedPath); } else { string folder = Path.GetFileName(selectedPath); dialog.SetFolder(FileDialogNative.CreateItemFromParsingName(parent)); dialog.SetFileName(folder); } } }