Create missing directories for dictionary files

Updated InterjectionsRepository to check if the dictionary directory exists before attempting to save files. If the directory does not exist, it will now be created automatically. This change prevents potential errors during file saving operations.

Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
This commit is contained in:
Ivandro Jao 2024-09-30 20:50:02 +01:00
parent a6bc467dab
commit 1a38183344

View File

@ -87,6 +87,11 @@ namespace Nikse.SubtitleEdit.Core.Common
} }
} }
if (!Directory.Exists(Configuration.DictionariesDirectory))
{
Directory.CreateDirectory(Configuration.DictionariesDirectory);
}
var fullFileName = Path.Combine(Configuration.DictionariesDirectory, userFileName); var fullFileName = Path.Combine(Configuration.DictionariesDirectory, userFileName);
xmlDocument.Save(fullFileName); xmlDocument.Save(fullFileName);
} }