diff --git a/src/Forms/SpellCheck.cs b/src/Forms/SpellCheck.cs index b321d5923..f0264289a 100644 --- a/src/Forms/SpellCheck.cs +++ b/src/Forms/SpellCheck.cs @@ -35,7 +35,6 @@ namespace Nikse.SubtitleEdit.Forms Dictionary _changeAllDictionary = new Dictionary(); List _userWordList = new List(); List _userPhraseList = new List(); - XmlDocument _userWordDictionary = new XmlDocument(); string _prefix = string.Empty; string _postfix = string.Empty; Hunspell _hunspell; @@ -253,14 +252,14 @@ namespace Nikse.SubtitleEdit.Forms string dictionary = Utilities.DictionaryFolder + _languageName; _userWordList = new List(); _userPhraseList = new List(); - _userWordDictionary = new XmlDocument(); string fileName = Utilities.DictionaryFolder + _languageName + "_user.xml"; if (File.Exists(fileName)) { try { - _userWordDictionary.Load(fileName); - foreach (XmlNode node in _userWordDictionary.DocumentElement.SelectNodes("word")) + var userWordDictionary = new XmlDocument(); + userWordDictionary.Load(fileName); + foreach (XmlNode node in userWordDictionary.DocumentElement.SelectNodes("word")) { string word = node.InnerText.Trim().ToLower(); if (word.Contains(" ")) @@ -272,15 +271,9 @@ namespace Nikse.SubtitleEdit.Forms catch (Exception exception) { MessageBox.Show("Unable to load user dictionary for " + _languageName + " from file: " + fileName + Environment.NewLine + - Environment.NewLine + - exception.Source + ": " + exception.Message); - _userWordDictionary.LoadXml(""); + Environment.NewLine + exception.Source + ": " + exception.Message); } } - else - { - _userWordDictionary.LoadXml(""); - } _changeAllDictionary = new Dictionary(); LoadHunspell(dictionary); @@ -446,10 +439,6 @@ namespace Nikse.SubtitleEdit.Forms else _userWordList.Add(s); Utilities.AddToUserDictionary(s, _languageName); - //XmlNode node = _userWordDictionary.CreateElement("word"); - //node.InnerText = s; - //_userWordDictionary.DocumentElement.AppendChild(node); - //_userWordDictionary.Save(_dictionaryFolder + _languageName + "_user.xml"); } break; case SpellCheckAction.AddToNamesEtc: @@ -1015,11 +1004,11 @@ namespace Nikse.SubtitleEdit.Forms _userWordList = new List(); _userPhraseList = new List(); - _userWordDictionary = new XmlDocument(); if (File.Exists(dictionaryFolder + _languageName + "_user.xml")) { - _userWordDictionary.Load(dictionaryFolder + _languageName + "_user.xml"); - foreach (XmlNode node in _userWordDictionary.DocumentElement.SelectNodes("word")) + var userWordDictionary = new XmlDocument(); + userWordDictionary.Load(dictionaryFolder + _languageName + "_user.xml"); + foreach (XmlNode node in userWordDictionary.DocumentElement.SelectNodes("word")) { string word = node.InnerText.Trim().ToLower(); if (word.Contains(" ")) @@ -1028,10 +1017,6 @@ namespace Nikse.SubtitleEdit.Forms _userWordList.Add(word); } } - else - { - _userWordDictionary.LoadXml(""); - } // Add names/userdic with "." or " " or "-" _wordsWithDashesOrPeriods = new List();