Ejemplo n.º 1
0
        /// <summary>
        /// InputTextBox receives String[] from Text file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenTextFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog {
                Filter = "txt files (*.txt)|*.txt",
                Title  = "Open Text file for decluttering:"
            };

            openFileDialog.ShowDialog();

            if (openFileDialog.FileName != String.Empty)               // Checking for empty names
            {
                System.IO.FileStream fileStream = (System.IO.FileStream)openFileDialog.OpenFile();

                TextReader textReader = new StreamReader(fileStream);
                InputTextBox.Clear();
                InputTextBox.AppendText(textReader.ReadToEnd());

                // Closing
                textReader.Close();
                fileStream.Close();
            }
        }