0

Help! I'm developing a program for a class and I'm a bit lost. My program needs to do the following:
1.) Open a text file using a file dialog box.
2.) Loop and read the file one line at a time using Readline().
3.) Display every line which has text that matches user-supplied string(textbox input) using IndexOf.
4.) Display the location of the match including character # and line # until end of file.

Here's what I have so far. I'm able to open the file dialog, select a text file, loop through the text file until the end.

This is my "Open File" button:

private void btnOpenFile_Click(object sender, EventArgs e)
        {
            if (dlgFileSelect.ShowDialog() == DialogResult.OK)
            {
                reader = new StreamReader(dlgFileSelect.FileName);
                lblCurrentFile.Text = "Current File: " + dlgFileSelect.FileName;
                
                do
                {  
                    storedtext = reader.ReadLine();
                } 
                while (!reader.EndOfStream);
                
                reader.Close();
                reader.Dispose();

            }

        }

I have no clue what to put in my "Search" button method. I have attached a screen shot of what my interface looks like, and I'm using a listbox to display step #3 from above ^^

All feedback is appreciated, Thanks!

Attachments programscreenshot.jpg 38.02 KB
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.