So I'm trying to read each line of a text file with streamreader, from there I go into a while loop to get to the end of the file the for loop is to print each of the tokens to the listbox. I feel like this should work!
EDIT: My question is how do I read a selected file, separate the words, and print them to the listbox?
if (openFile.ShowDialog() == DialogResult.OK)
{
StreamReader inputFile;
inputFile = File.OpenText(openFile.FileName);
string line;
//int totalWords;
char[] delim = { '.', '!', '?', ',', '(', ')' };
while (!inputFile.EndOfStream)
{
line = inputFile.ReadLine();
string[] tokens = line.Split(delim);
for (int i = 0; i < tokens.Length; i++)
{
wordListBox.Items.Add(tokens[i]);
}
}
inputFile.Close();
}