summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-31 01:50:31 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-31 01:50:31 -0400
commit80d5672cdb04e8cba40b085b32ffcaf1fea78552 (patch)
tree14a5b5b43726d9d030c25cace74798aee09a0263 /src
parentdc78d944e8663c02f305bbadff1c13e8c63eb42f (diff)
downloadSMAPI-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.cs13
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