Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. private Trie game_dictionary = new Trie();
  2. private bool loading_dictionary = true;
  3. private void GenerateDictionary(object path)
  4. {
  5.     var uri = new Uri(path.ToString());
  6.     var resourceStream = Application.GetResourceStream(uri);
  7.     using (StreamReader sr = new StreamReader(resourceStream.Stream))
  8.     {
  9.         while (sr.Peek() >= 0)
  10.         {
  11.             string word = sr.ReadLine(); //only one word per line in PolishDictionary
  12.             if (game_dictionary.AcceptableWord(word)) game_dictionary.AddWord(word);
  13.         }
  14.     }
  15.     using (var fs = new System.IO.FileStream("dict.dat", FileMode.CreateNew, FileAccess.Write))
  16.     {
  17.         var bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
  18.         bf.Serialize(fs, game_dictionary);
  19.            }
  20.     loading_dictionary = false;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement