I'm trying to use the .NET class OpenFileDialog in C++ and getting a weird bug. My basic code is below.
OpenFileDialog^ openFileDialog = gcnew OpenFileDialog;
openFileDialog->InitialDirectory = "c:\\";
openFileDialog->Filter = "Bitmap|*.bmp|All Files|*.*";
openFileDialog->FilterIndex = 1;
openFileDialog->RestoreDirectory = true;
if (openFileDialog->ShowDialog() == DialogResult::OK)
MessageBox::Show(openFileDialog->FileName, "Information", MessageBoxButtons::OK, MessageBoxIcon::Information);
When the code reaches this point, the dialog opens as expected. But if I switch the "Files of type" pull-down, as a user might, the files and directories that are listed in the dialog window disappear (irrespective of the filter). If I go up to the parent directory, and re-enter the same child directory, then the files and directories are properly displayed, filtered as expected. Does anyone have any idea why I might be getting this weird bug?
FYI, I'm on a Windows XP 64-bit SP2, building with Visual Studio 2010 for .NET 4.