c# - 使用 Word 字典检查某个单词是否存在

标签 c# dictionary ms-word vsto spell-checking

我正在使用 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/

相关文章:

python - 将元组列表映射到字典中

python - 从 Python 字典中访问多个数据

c# - .Net Async ContinueWith VS 在任务中嵌入任务

c# - 如何在 C# 中将声明作为标志(bool)添加到 SystemUser

c# - 无法加载程序集 'Xamarin.Android.Support.v4'

c# - C++-STL映射和Boost的unordered_map的更好替代方案?

c# - Google c# Api,从 v2.3 更改为 v3

c# - 使用 C# 向 word 文档添加行

c# - 是否有任何与word文档相关的元数据?

templates - 在 Word 2013 中添加自定义 "template group"