stephenlecomptejr
asked on
openFileDialog1 pops up when I try to browse for a file using C# FileDialog
All,
Please note with the following code that for some reason puts openFileDialog1 as the filename - so if someone were to click Open it tries to say the name they are selecting is openFileDialog1. I find that to be annoying - is there anything in the following code that I'm using incorrectly in the syntax causing this?
Please note result in attachment!
Please note with the following code that for some reason puts openFileDialog1 as the filename - so if someone were to click Open it tries to say the name they are selecting is openFileDialog1. I find that to be annoying - is there anything in the following code that I'm using incorrectly in the syntax causing this?
Please note result in attachment!
if (rbSingle.Checked == true)
{
string defaultpath = txtPath.Text;
string newfile = "";
fdPath.InitialDirectory = defaultpath;
DialogResult result = this.fdPath.ShowDialog();
if (result == DialogResult.OK)
{
newfile = fdPath.FileName;
if (newfile != "openFileDialog1")
{
ShowMyMessageBox(@"File must be a PDF");
}
if (newfile.Substring(0, 1) != "C")
{
ShowMyMessageBox(@"File must be located locally on your C:\drive");
}
else
{
//fileName.Substring(fileName.Length - 4)
if (newfile.Substring(newfile.Length - 4) != ".pdf")
{
}
else
{
txtPath.Text = newfile;
this.Height = 516;
}
}
}
}
openFileDialog1.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
string defaultpath = txtPath.Text;
which never, ever has openFileDialog1....
which never, ever has openFileDialog1....
ASKER
Thank you dustock
No problem
What value does defaultpath have?