Hold down Ctrl to avoid using folder browse dlg

That dialog just plain sucks...you can't type in a path, for instance.
This commit is contained in:
flarn2006 2013-12-17 19:17:15 -05:00
parent 366ec3fe9e
commit 400eb1f80a

View file

@ -162,6 +162,8 @@ namespace NBTExplorer.Windows
if (!ConfirmAction("Open new folder anyway?"))
return;
if ((ModifierKeys & Keys.Control) == 0) {
// if the user isn't holding Control, use the standard folder browser dialog
using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
if (_openFolderPath != null)
ofd.SelectedPath = _openFolderPath;
@ -171,6 +173,21 @@ namespace NBTExplorer.Windows
OpenPaths(new string[] { ofd.SelectedPath });
}
}
} else {
// otherwise, use a file open dialog and open whichever directory has the selected file
using (OpenFileDialog ofd = new OpenFileDialog()) {
ofd.Title = "Select any file in the directory to open";
ofd.Filter = "All files (*.*)|*.*";
if (_openFolderPath != null)
ofd.InitialDirectory = _openFolderPath;
if (ofd.ShowDialog() == DialogResult.OK) {
_openFolderPath = Path.GetDirectoryName(ofd.FileName);
OpenPaths(new string[] { _openFolderPath });
}
}
}
UpdateUI();
}