private void SaveUserDictionaryToFile() { try { var userDictionaryPath = GetUserDictionaryPath(Settings.Default.KeyboardAndDictionaryLanguage); Log.DebugFormat("Saving user dictionary to file '{0}'", userDictionaryPath); StreamWriter writer = null; try { writer = new StreamWriter(userDictionaryPath); foreach (var entryWithUsageCount in manageAutoComplete.GetWordsHashes().SelectMany(hash => entries[hash]).Distinct()) { writer.WriteLine("{0}|{1}", entryWithUsageCount.Entry, entryWithUsageCount.UsageCount); } } finally { if (writer != null) { writer.Dispose(); } } } catch (Exception exception) { PublishError(this, exception); } }