public static void OpenPictureSaveDirectory(HSSettings settingsContext) { var path = settingsContext.ExpandedSavePath; if (string.IsNullOrWhiteSpace(path)) { NotificationManager.NoPathSpecified(); return; } var ensuredDestinationDirectory = GetAndEnsureDestinationDirectory(settingsContext); if (ensuredDestinationDirectory == null) { NotificationManager.PathDoesNotExist(path); return; } if (!string.IsNullOrEmpty(_lastFileName) && File.Exists(_lastFileName)) { HolzShotsPaths.OpenSelectedFileInExplorer(_lastFileName); } else { HolzShotsPaths.OpenFolderInExplorer(path); } }
private static string?GetAndEnsureDestinationDirectory(HSSettings settingsContext) { var resolvedPath = settingsContext.ExpandedSavePath; Debug.Assert(!string.IsNullOrEmpty(resolvedPath)); try { HolzShotsPaths.EnsureDirectory(resolvedPath); return(resolvedPath); } catch (UnauthorizedAccessException) { NotificationManager.UnauthorizedAccessExceptionDirectory(resolvedPath); return(null); } catch (PathTooLongException) { NotificationManager.PathIsTooLong(resolvedPath); return(null); } }