How to opet text file via open file dialog and print text?
gogs85
0
Junior Poster in Training
Recommended Answers
Jump to Postgoogle streamread and streamwrite
Jump to Postto open a text file using an OpenFileDialog and show it in a MessageBox:
private void button1_Click(object sender, System.EventArgs e) { if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName); MessageBox.Show(sr.ReadToEnd()); sr.Close(); } }
All 7 Replies
Cameronsmith63
9
Light Poster
agugglez
0
Newbie Poster
gogs85
0
Junior Poster in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
Chellam2
0
Newbie Poster
gogs85
0
Junior Poster in Training
zachattack05
70
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.