[英]exception in c# exe using NHUspell
I have a problem with my project. 我的项目有问题。
This is a project for my university. 这是我大学的一个项目。
I decided to add HNUSpell from nuget package in order to check spelling It works well in code but unfortunately whn I make an .exe from it I face with this Exception: 我决定从nuget包中添加HNUSpell以便检查拼写。它在代码中效果很好,但是不幸的是,当我从其中创建一个.exe时,遇到了此异常:
here is code: 这是代码:
using (Hunspell hunspell = new Hunspell("en_US.aff", "fa.dic"))
{
string[] lines = System.IO.File.ReadAllLines("New Text Document (2).txt");
foreach (var line in lines)
{
line.Replace(" " , string.Empty);
hunspell.Add(line);
}
List<string> suggestions = hunspell.Suggest(myInput);
foreach (string suggestion in suggestions)
{
//Do something
}
I really got confused and don't what should I do. 我真的很困惑,不要做什么。
Can anyone please help me? 谁能帮帮我吗?
thanks in advance 提前致谢
In the first line of your code snippet you specify the path to the aff file: 在代码段的第一行中,指定aff文件的路径:
using (Hunspell hunspell = new Hunspell("en_US.aff", "fa.dic"))
You provide a relative path "en_US.aff"
. 您提供了相对路径"en_US.aff"
。 When you run your program the exception occurs, because the file can't be found nearby. 运行程序时会发生异常,因为在附近找不到该文件。
What you could do is specifying a absolute path instead of a relative one: 您可以做的是指定绝对路径,而不是相对路径:
new Hunspell("C:\somePath\en_US.aff", "C:\somePath\fa.dic"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.