我正在使用 C# 和 VSTO 开发 Word 2010 插件。 我想知道是否可以检查 Word 字典中是否存在某个单词?
我找到这个 var dict = Application.CustomDictionaries.ActiveCustomDictionary;
但我不知道如何使用它来检查某个单词是否存在。
有什么想法吗?
最佳答案
您可以手读字典文件,检查列表中是否存在该词。
试试这个:
string[] words = File.ReadAllLines(Path.Combine(Globals.ThisAddIn.Application.CustomDictionaries[1].Path, Globals.ThisAddIn.Application.CustomDictionaries[1].Name));
bool wordExists = words.Contains("yourWord");
注意:
您的示例读取自定义词典,而不是 Word 内部词典。据我所知,无法阅读默认词典。
关于c# - 使用 Word 字典检查某个单词是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22185899/