private void btnRead_Click_1(object sender, EventArgs e)
{try{
FileStream f = new FileStream("demo.txt", FileMode.OpenOrCreate, FileAccess.Read);
StreamReader sr = new StreamReader(f);
tb1.Text = sr.ReadToEnd();
sr.Close();
f.Close();
}Catch(Exception ee){
MessageBox.Show(ee.Message);
}
}
I tried your code in linqpad, everything works fine. However, there's a typo, the 'Catch' should be 'catch' though.
You can set a break point on the reader, and see if it read anything.
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.