Switching the "Files of type" pull-down in .NET OpenFileDialog clears the list of files bug
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 开发者_JAVA技巧.NET 4.
This is pure operating system behavior. The dialog lives in the shell, the .NET wrapper class is a very thin one around GetOpenFileName().
I don't know much about XP x64, except that it was training wheels for Vista x64. It wasn't done with several COM servers not yet translated to x64. And that it didn't get the SP3 update sounded iffy to me. You can assume that your customer is unlikely to see the same problem. I'm not close to one right now to verify that.
精彩评论