private void LoadWords() { lock (_lock) { if (_words == null) { _words = new SafeDictionary <string, int>();// new SafeSortedList<string, int>(); } if (File.Exists(_Path + _FileName + ".words") == false) { return; } // load words byte[] b = File.ReadAllBytes(_Path + _FileName + ".words"); if (b.Length == 0) { return; } MemoryStream ms = new MemoryStream(b); BinaryReader br = new BinaryReader(ms, Encoding.UTF8); string s = br.ReadString(); while (s != "") { int off = br.ReadInt32(); _words.Add(s, off); try { s = br.ReadString(); } catch { s = ""; } } _log.Debug("Word Count = " + _words.Count()); _wordschanged = true; } }
/// <summary> /// Load Words /// </summary> private void LoadWords() { lock (_lock) { if (_words == null) { _words = new SafeDictionary <string, int>(); } // new SafeSortedList<string, int>(); if (!File.Exists(Path.Combine(HootConfOptions.IndexPath, $"{HootConfOptions.FileName}.words")) == false) { // load words using (FileStream words = new FileStream(Path.Combine(HootConfOptions.IndexPath, $"{HootConfOptions.FileName}.words"), FileMode.Open)) { if (words.Length == 0) { return; } using (BinaryReader br = new BinaryReader(words, Encoding.UTF8)) { string s = br.ReadString(); while (s != "") { int off = br.ReadInt32(); _words.Add(s, off); try { s = br.ReadString(); } catch { s = ""; } } } } _log.Debug("Word Count = " + _words.Count()); _wordschanged = true; } } }