-1

I looked around for an answer to this and couldn't find anything. All I need to do is take an input from a text file with multiple lines selected from an OpenFileDialog box. Here's a selection from my code:

if (theDialog.ShowDialog() == DialogResult.OK)
        {
            try
            {
                if ((myStream = theDialog.OpenFile()) != null)
                {
                    using (myStream)
                    {
                        //I need this to take input given from OpenFileDialog

                        
                        this.read_display.Text = input;
                    }
                }
            }

I'm probably just overlooking something really obvious, but I'm not sure.

1 Answers1

0

If you want to get the text from stream, you can create a StreamReader instance and call method ReadToEnd().

string input;
using (StreamReader sr = new StreamReader(myStream))
{
    input = sr.ReadToEnd());
}
大陸北方網友
  • 3,696
  • 3
  • 12
  • 37