Sometimes, when I call ShowDialog in the OpenFileDialog Window in WPF, the dialog closes immediately with a false value returned.
I call ShowDialog in response to a button click event. I can reproduce this problem using the sample code for OpenFileDialog on MSDN:
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document";
dlg.DefaultExt = ".txt";
dlg.Filter = "Text documents (.txt)|*.txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
}
The problem occurs intermittently when I run my solution in debug mode from Visual Studio 2008 SP1. This is pretty annoying.
Is this a known issue? Are there any workarounds?
source
share