Data Directory changes

1.Added data directory check for desktop.
2. Set default data directory to root folder of installation path.
This commit is contained in:
Brett Hewitson 2021-12-01 12:50:21 +10:00
parent 1767cd0a83
commit e3dd4201fc
10 changed files with 38 additions and 20 deletions

View file

@ -402,6 +402,9 @@ namespace ServerManagerTool
if (!installationFolder.EndsWith(@"\"))
installationFolder += @"\";
var desktopFolder1 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var desktopFolder2 = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
while (String.IsNullOrWhiteSpace(Config.Default.DataPath))
{
var dialog = new CommonOpenFileDialog
@ -410,7 +413,7 @@ namespace ServerManagerTool
IsFolderPicker = true,
Multiselect = false,
Title = _globalizer.GetResourceString("Application_DataDirectory_DialogTitle"),
InitialDirectory = installationFolder
InitialDirectory = Path.GetPathRoot(installationFolder)
};
if (dialog.ShowDialog() != CommonFileDialogResult.Ok)
@ -428,7 +431,12 @@ namespace ServerManagerTool
if (newDataFolder.StartsWith(installationFolder))
{
confirm = MessageBoxResult.No;
MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_WithinInstallFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_WithinInstallFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinInstallFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
}
else if (newDataFolder.StartsWith(desktopFolder1) || newDataFolder.StartsWith(desktopFolder2))
{
confirm = MessageBoxResult.No;
MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinDesktopFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{

View file

@ -97,8 +97,9 @@
<sys:String x:Key="Application_DataDirectory_DialogTitle">Select a Data Directory</sys:String>
<sys:String x:Key="Application_DataDirectory_ConfirmTitle">Confirm location</sys:String>
<sys:String x:Key="Application_DataDirectory_ConfirmLabel">The server manager will store profiles and SteamCMD in the following directories:\r\n\r\nProfiles: {0}\r\nSteamCMD: {1}\r\n\r\nIs this ok?</sys:String>
<sys:String x:Key="Application_DataDirectory_WithinInstallFolderErrorTitle">Data Directory Selection Error</sys:String>
<sys:String x:Key="Application_DataDirectory_WithinInstallFolderErrorLabel">The directory you have chosen is within the server manager installation folder. This is not recommended, please choose another folder.</sys:String>
<sys:String x:Key="Application_DataDirectory_DataDirectoryFolderErrorTitle">Data Directory Selection Error</sys:String>
<sys:String x:Key="Application_DataDirectory_DataDirectoryWithinInstallFolderErrorLabel">The directory you have chosen is within the server manager installation folder. This is not recommended, please choose another folder.</sys:String>
<sys:String x:Key="Application_DataDirectory_DataDirectoryWithinDesktopFolderErrorLabel">The directory you have chosen is on the desktop. This is not recommended, please choose another folder.</sys:String>
<sys:String x:Key="Application_Profile_SaveFailedTitle">Failed to save profile</sys:String>
<sys:String x:Key="Application_Profile_SaveFailedLabel">Failed to save profile {0}. {1}\n{2}</sys:String>