I'm new to VS and trying to use NHunSpell in my project. After the usual effort, I think I'm on the right track and one last problem remains: how to add the .dic
and .aff
files and have them present in my project.
I've installed NHunSpell via NuGet so it's included in the project when I commit.
So far, I have tried:
.dll
directoriesThe problem is that the Hunspell constructor expects two string arguments pointing to the files, like so:
Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic");
...so even when I am successful at adding them as a resource, they are a) byte arrays and b) not included when I build the project. I have built the project successfully with absolute paths to the local machine, but this obviously isn't optimal.
So, how can I add these paths to the build (and subsequent commit so future pull-ers can use them)?
Ah-ha - after way too long, looks like the solution is Server.MapPath
:
Hunspell hunspell = new Hunspell(
System.Web.HttpContext.Current.Server.MapPath("~/Assets/dictionaries/en_us.aff"),
System.Web.HttpContext.Current.Server.MapPath("~/Assets/dictionaries/en_us.dic")
);
To test where the base path is, you can use:
string s = System.AppDomain.CurrentDomain.BaseDirectory;