Hello,
It looks like what you are trying to do is to open a file dialog and
return the name of the file chosen by the user. If this is the case,
then the following code will suffice...
string fileName = "";
OpenFileDialog ofd = new OpenFileDialog();
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
fileName = ofd.FileName;
}
--
Cheers,
Gary
http://www.garyshort.org/
> The following code was supplied by a kind poster as a solution to a
> problem i was having. But it's not quite working. I have commented the
[quoted text clipped - 39 lines]
> }
> }
garyusenet@myway.com - 23 Nov 2006 13:00 GMT
Thankyou. I tried your code and now have the following: -
namespace MyNamespace
{
public partial class Form1 : Form
{
private void Form1_Load(object sender, EventArgs e)
{
string fileName = "";
OpenFileDialog ofd = new OpenFileDialog();
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
fileName = ofd.FileName;
}
}
}
}
But i still have the same problem, all i have when i run the program is
a blank form, and the open file dialog box isn't displayed.
Please advise,
Gary.
garyusenet@myway.com - 23 Nov 2006 14:35 GMT
Bump! any advances?
gary@garyshort.org - 23 Nov 2006 16:03 GMT
Try cutting the code out of the form load handler and putting it in a
button click handler and see how you go. That code works for me in both
handlers so I'm not sure what your problem is.
--
Cheers,
Gary
http://www.garyshort.org/
> Bump! any advances?