private void SetDialogProperties(NativeMethods.IFileDialog dialog)
{
if (!String.IsNullOrEmpty(Description))
{
if (UseDescriptionForTitle)
dialog.SetTitle(Description);
else
((NativeMethods.IFileDialogCustomize)dialog).AddText(0, Description);
}
dialog.SetOptions(
NativeMethods.FOS.FOS_PICKFOLDERS |
NativeMethods.FOS.FOS_FORCEFILESYSTEM |
NativeMethods.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(CreateItemFromParsingName(parent));
dialog.SetFileName(folder);
}
}
}