public void ShowFolderBrowserDialog(string defaultPath, string description, bool showNewFolderButton, Action<DialogResult, string> callback)
{
if (callback == null)
throw new ArgumentNullException("callback");
using (var dlg = new FolderBrowserDialog())
{
dlg.SelectedPath = defaultPath;
dlg.Description = description;
dlg.ShowNewFolderButton = showNewFolderButton;
var result = dlg.ShowDialog();
try
{
callback(result, dlg.SelectedPath);
}
catch (Exception ex)
{
_log.Error("Error invoking callback.", ex);
}
}
}