Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an InitialDirectory property to the folder browser dialog #44

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ public string Description
[Localizable(false), Description("The root folder where the browsing starts from. This property has no effect if the Vista style dialog is used."), Category("Folder Browsing"), Browsable(true), DefaultValue(typeof(System.Environment.SpecialFolder), "Desktop")]
public System.Environment.SpecialFolder RootFolder { get; set; }

/// <summary>
/// Gets or sets the initial directory where the browsing starts from. This property only affects the Vista style dialog.
/// </summary>
/// <value>
/// The path of the directory where the folder browsing should start. The dfault is <see langword="null"/>.
/// </value>
[Browsable(true), Description("The initial directory where the browsing starts from. This property only affects the Vista style dialog."), Category("Folder Browsing"), DefaultValue(null)]
public string InitialDirectory { get; set; }

/// <summary>
/// Gets or sets the path selected by the user.
/// </summary>
Expand Down Expand Up @@ -291,6 +300,11 @@ private void SetDialogProperties(Ookii.Dialogs.Wpf.Interop.IFileDialog dialog)
dialog.SetFileName(folder);
}
}

if( Directory.Exists(this.InitialDirectory) )
{
dialog.SetFolder(NativeMethods.CreateItemFromParsingName(this.InitialDirectory));
}
}

private void GetResult(Ookii.Dialogs.Wpf.Interop.IFileDialog dialog)
Expand Down