What is the best way to allow a user to view a file in C #?

What is the best way to allow a user to view a file in C #?

+6
c #
source share
3 answers
using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Select a file"; if (dlg.ShowDialog()== DialogResult.OK) { //do something with dlg.FileName } } 
+15
source share

I would say using the standard OpenFileDialog dialog box, this makes it less intimidating for new users and helps with a consistent interface.

+1
source share

Close, Ryan, but you never showed a dialogue. it should be:

 if (dlg.ShowDialog() == DialogResult.OK) 
+1
source share

All Articles