Browsing to a file in forms
-
Hi there. I am wondering how one goes about doing what is done in email, clicking a button and then you can browse to a file that you want to attach. I want to be able to do this in a windows form app. I dont´know what it is called but when the user presses button he/she can go to a location on the computer and get the path of a file and then something can be done with the file. I wish I could explain better what I mean but I am sure most will know what I am referring to. Thanks F
-
Hi there. I am wondering how one goes about doing what is done in email, clicking a button and then you can browse to a file that you want to attach. I want to be able to do this in a windows form app. I dont´know what it is called but when the user presses button he/she can go to a location on the computer and get the path of a file and then something can be done with the file. I wish I could explain better what I mean but I am sure most will know what I am referring to. Thanks F
-
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Text files (*.txt)|*.txt|Bitmaps|*.bmp|All Files|*.*";
DialogResult res = dlg.ShowDialog();
if(res == DialogResult.OK)
{
Console.WriteLine(dlg.FileName); // here we have our file
}regards :)