Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenFileDialog Issue: Can't Retrieve Filename!

Status
Not open for further replies.

NipsMG

Programmer
Dec 27, 2000
215
US
I'm trying to use the ResEditor sample in the .NET Framework.

There's code for an "Open File " Dialog box as listed below:
Code:
if (openFileDialog1.ShowDialog() == DialogResult.OK) 

			{
				currentFileName =  openFileDialog1.FileName;

				FileInfo efInfo = new FileInfo(currentFileName);

...

No matter what File I select, or from what directory, openFileDialog1.FileName is ALWAYS BLANK.

I can't retrieve the selected filename.

Does anyone know why?!
 
This works for me, where the "this" is a winform.
Code:
if (ofDialog.ShowDialog(this) == DialogResult.OK)
{
   this.Controller.LoadScript(ofDialog.FileName);
Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
I get AssemblyName.FormName does not contain a definition for Controller.
 
Controller and it's method LoadScript is from my code. They're just there as an example.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
What you might want to do is break it up into individual assignments, so that you can use the Autos and Local debugger windows to inspect their values.
Code:
DialogResult dr;

dr = ofDialog.ShowDialog(this);

//Inspect dr
if (dr == DialogResult.OK
{
   string s = ofDialog.FileName;
   //Inspect s


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top