diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-31 01:50:31 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-31 01:50:31 -0400 |
commit | 80d5672cdb04e8cba40b085b32ffcaf1fea78552 (patch) | |
tree | 14a5b5b43726d9d030c25cace74798aee09a0263 /src | |
parent | dc78d944e8663c02f305bbadff1c13e8c63eb42f (diff) | |
download | SMAPI-80d5672cdb04e8cba40b085b32ffcaf1fea78552.tar.gz SMAPI-80d5672cdb04e8cba40b085b32ffcaf1fea78552.tar.bz2 SMAPI-80d5672cdb04e8cba40b085b32ffcaf1fea78552.zip |
fix crash when farm name contains invalid-in-file-path characters (#791)
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Constants.cs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 9e93551c..6fb796de 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -351,9 +351,16 @@ namespace StardewModdingAPI DirectoryInfo folder = null; foreach (string saveName in new[] { rawSaveName, new string(rawSaveName.Where(char.IsLetterOrDigit).ToArray()) }) { - folder = new DirectoryInfo(Path.Combine(Constants.SavesPath, $"{saveName}_{saveID}")); - if (folder.Exists) - return folder; + try + { + folder = new DirectoryInfo(Path.Combine(Constants.SavesPath, $"{saveName}_{saveID}")); + if (folder.Exists) + return folder; + } + catch (ArgumentException) + { + // ignore invalid path + } } // if save doesn't exist yet, return the default one we expect to be created |