This seems to be very simple but for some reason I cannot get it to work.
I am building a small C# utility that uses Open File Dialog to select an XML file from a directory. That part works fine.
The file is transferred to a web service and a response is received. No problem.
I simply want to open up the DestDirectory where the response is placed. However, no matter what I end up with the Open File Dialog opening up the directory from the first usage.
I have tried two instances of Open File Dialog on the form.
OpenFD1.Reset();
Resetting all the value programatically,ie initialDirectory
It seems very simple to do what I want to do but I am not seeing the answer.
Here is part of the code: I have two buttons on the form that I want to use to open up the dialog.
public void button1_Click(object sender, EventArgs e)
{
OpenFD1.Title = "Open Test File";
OpenFD1.Filter = "XML Files|*.xml";
string SourceDir = AppSetting("SourceDir");
OpenFD1.InitialDirectory = SourceDir;
if (OpenFD1.ShowDialog() == DialogResult.OK)
{
sSelectedFile = OpenFD1.FileName.ToString();
WFileName.Text = OpenFD1.FileName.ToString();
}
OpenFD1.CheckFileExists = true;
OpenFD1.CheckPathExists = true;
OpenFD1.InitialDirectory = null; ;
}
private void button3_Click(object sender, EventArgs e)
{
OpenFD2.FileName = null;
OpenFD2.Title = "Test Results";
OpenFD2.Filter = "XML Files|*.xml";
string DestDir = AppSetting("DestDir");
OpenFD2.InitialDirectory = DestDir;
if (OpenFD2.ShowDialog() == DialogResult.OK)
{
sSelectedFile = OpenFD2.FileName.ToString();
WFileName.Text = OpenFD2.FileName.ToString();
}
OpenFD2.CheckFileExists=true;
OpenFD2.CheckPathExists = true;
}