diff --git a/Assets/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll b/Assets/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll index a5164a5..1b2fc63 100755 Binary files a/Assets/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll and b/Assets/StandaloneFileBrowser/Plugins/Ookii.Dialogs.dll differ diff --git a/Assets/StandaloneFileBrowser/StandaloneFileBrowserWindows.cs b/Assets/StandaloneFileBrowser/StandaloneFileBrowserWindows.cs index 2bdb8c2..6e83e2b 100755 --- a/Assets/StandaloneFileBrowser/StandaloneFileBrowserWindows.cs +++ b/Assets/StandaloneFileBrowser/StandaloneFileBrowserWindows.cs @@ -24,6 +24,8 @@ public class StandaloneFileBrowserWindows : IStandaloneFileBrowser { public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect) { var fd = new VistaOpenFileDialog(); fd.Title = title; + fd.InitialDirectory = directory; + fd.Multiselect = multiselect; if (extensions != null) { fd.Filter = GetFilterFromFileExtensionList(extensions); fd.FilterIndex = 1; @@ -31,10 +33,6 @@ public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] else { fd.Filter = string.Empty; } - fd.Multiselect = multiselect; - if (!string.IsNullOrEmpty(directory)) { - fd.FileName = GetDirectoryPath(directory); - } var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); var filenames = res == DialogResult.OK ? fd.FileNames : new string[0]; fd.Dispose(); @@ -48,11 +46,10 @@ public void OpenFilePanelAsync(string title, string directory, ExtensionFilter[] public string[] OpenFolderPanel(string title, string directory, bool multiselect) { var fd = new VistaFolderBrowserDialog(); fd.Description = title; - if (!string.IsNullOrEmpty(directory)) { - fd.SelectedPath = GetDirectoryPath(directory); - } + fd.RootFolder = Environment.SpecialFolder.MyComputer; + fd.SelectedPath = directory; var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); - var filenames = res == DialogResult.OK ? new []{ fd.SelectedPath } : new string[0]; + var filenames = res == DialogResult.OK ? new[] { fd.SelectedPath } : new string[0]; fd.Dispose(); return filenames; } @@ -64,18 +61,8 @@ public void OpenFolderPanelAsync(string title, string directory, bool multiselec public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) { var fd = new VistaSaveFileDialog(); fd.Title = title; - - var finalFilename = ""; - - if (!string.IsNullOrEmpty(directory)) { - finalFilename = GetDirectoryPath(directory); - } - - if (!string.IsNullOrEmpty(defaultName)) { - finalFilename += defaultName; - } - - fd.FileName = finalFilename; + fd.InitialDirectory = directory; + fd.FileName = defaultName; if (extensions != null) { fd.Filter = GetFilterFromFileExtensionList(extensions); fd.FilterIndex = 1; @@ -100,6 +87,7 @@ public void SaveFilePanelAsync(string title, string directory, string defaultNam // .NET Framework FileDialog Filter format // https://msdn.microsoft.com/en-us/library/microsoft.win32.filedialog.filter private static string GetFilterFromFileExtensionList(ExtensionFilter[] extensions) { + if (extensions == null) return ""; var filterString = ""; foreach (var filter in extensions) { filterString += filter.Name + "("; @@ -120,17 +108,6 @@ private static string GetFilterFromFileExtensionList(ExtensionFilter[] extension filterString = filterString.Remove(filterString.Length - 1); return filterString; } - - private static string GetDirectoryPath(string directory) { - var directoryPath = Path.GetFullPath(directory); - if (!directoryPath.EndsWith("\\")) { - directoryPath += "\\"; - } - if (Path.GetPathRoot(directoryPath) == directoryPath) { - return directory; - } - return Path.GetDirectoryName(directoryPath) + Path.DirectorySeparatorChar; - } } }