public static Primitive GetFolder(Primitive InitialFolder)
{
Primitive result = "";
try
{
ThreadStart start = delegate
{
System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
dlg.RootFolder = Environment.SpecialFolder.MyComputer;
dlg.SelectedPath = LastFolder;
if (InitialFolder != "") dlg.SelectedPath = InitialFolder;
if (dlg.ShowDialog(Utilities.ForegroundHandle()) == System.Windows.Forms.DialogResult.OK)
{
result = dlg.SelectedPath;
LastFolder = result;
}
};
Thread thread = new Thread(start);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
StartPosition(null, "Browse For Folder");
thread.Join();
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return result;
}