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.
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());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.