Beispiel #1
0
        /// <summary>
        /// One click on the top left "Fill" button fills the lbWords listbox with our entire resource "WordList.txt" file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFill_Click(object sender, EventArgs e)
        {
            #region The Old Way

#if false
            string     s;
            FileStream fs;

            try
            {
                fs = new FileStream(@"..\..\WordList.txt", FileMode.Open, FileAccess.Read);
            }
            catch
            {
                MessageBox.Show("Unable to open WordList.txt");
                return;
            }

            StreamReader sr = new StreamReader(fs);

            lbWords.BeginUpdate();
            lbWords.Items.Clear();
            while ((s = sr.ReadLine()) != null)
            {
                lbWords.Items.Add(s);
            }
            lbWords.EndUpdate();
#endif

            #endregion
            lbWords.BeginUpdate();
            lbWords.Items.Clear();
            string[] allWords = word.PrintAll();
            foreach (string words in allWords)
            {
                lbWords.Items.Add(words);
            }
            lbWords.EndUpdate();
        }