/// <summary> /// 填充字典 /// </summary> /// <param name="dictSeg"></param> /// <param name="dicPath"></param> private void FillDictSegment(DictionarySegment dictSeg, string dicPath) { dicPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dicPath); if (!File.Exists(dicPath)) { throw new FileNotFoundException(dicPath + " Dictionary not found!!!"); } try { var theWordLines = File.ReadAllLines(dicPath); foreach (var theWord in theWordLines) { if (!string.IsNullOrEmpty(theWord.Trim())) { dictSeg.FillSegment(theWord.Trim().ToCharArray()); } } } catch (IOException ioe) { System.Console.WriteLine(dicPath + " Dictionary loading exception."); System.Console.WriteLine(ioe.StackTrace); } }