/// <summary> /// 在词典文件夹中查找字典文件,返回包含词典文件名的列表 /// </summary> /// <returns></returns> public static List <string> ReadDictList() { List <string> list = new List <string>(); string[] files = Directory.GetFiles(AppInfoHelper.GetDictionaryFolder()); foreach (string f in files) { if (Path.GetExtension(f) == ".xml") { list.Add(Path.GetFileNameWithoutExtension(f)); } } return(list); }
/// <summary> /// 生成包含网络词典的“词典-路径”字典 /// </summary> /// <returns></returns> public static Dictionary <string, string> ReadDictDict() { Dictionary <string, string> dictDict = new Dictionary <string, string>(); List <string> dictList = AppInfoHelper.GetDictList(); for (int i = 0; i < dictList.Count; i++) { if (dictList[i] == "有道词典") { dictDict.Add("有道词典", @"http://dict.youdao.com/search?q="); } else { dictDict.Add(dictList[i], String.Format("{0}\\{1}.xml", AppInfoHelper.GetDictionaryFolder(), dictList[i])); } } return(dictDict); }
public static void UpdateDict() { List <string> list = new List <string>(); list = DictHelper.ReadDictList(); XmlDocument xdoc = new XmlDocument(); xdoc.Load(Environment.CurrentDirectory + "\\WordData.xml"); XmlNode root = xdoc.DocumentElement; foreach (XmlNode node in root.ChildNodes) { if (node["update"].InnerText == true.ToString()) { for (int i = 0; i < list.Count; i++) { DictHelper.SetDictProgress(AppInfoHelper.GetDictionaryFolder() + "\\" + list[i] + ".xml", node["word"].InnerText, node["progress"].InnerText); } node["update"].InnerText = false.ToString(); } } xdoc.Save(Environment.CurrentDirectory + "\\WordData.xml"); }