How to: Add Dictionaries from an Assembly Resource
The code sample below shows how to use the GetExecutingAssembly() and GetManifestResourceInfo(String) methods to deploy dictionaries in the application’s assembly.
The LoadFromStream(Stream, Stream, Stream) method allows you to load dictionary files from a stream.
When you load dictionaries from assembly resources, make sure that the dictionary files’ Build Action property is set to Embedded Resource.
private void Form1_Load(object sender, EventArgs e)
{
//Create a new dictionary instance
SpellCheckerISpellDictionary dictionary = new SpellCheckerISpellDictionary();
//Create stream objects for each dictionary file
Stream affStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication27.Dictionaries.english.aff");
Stream dicStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication27.Dictionaries.american.xlg");
Stream alphStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication27.Dictionaries.EnglishAlphabet.txt");
//Load files to the dictionary
dictionary.LoadFromStream(dicStream, affStream, alphStream);
//Add dictionary to the spell checker collection
spellChecker1.Dictionaries.Add(dictionary);
}