issue opened here : https://github.com/dotnet/core/issues/9137
[BUG] System::Windows::Forms::OpenFileDialog::AutoUpgradeEnabled does not work correctly with NetCore 8.0
Pierre Chatelier
81
Reputation points
When setting AutoUpgradeEnabled
to false
in an System::Windows::Forms::OpenFileDialog
- everything goes right in a .Net 4.8 project
- no filenames are returned when exiting the dialog in a .Net 8.0 project (netcore8.0-windows)
To be able to use System::Windows::Forms::OpenFileDialog
in a NetCore 8.0 project, <UseWindowsForms>true</UseWindowsForms>
must be used.
I don't know if it's relevant, but I have also referenced Microsoft.Windows.Compatibility
in my project.
Is there any workaround ?
I need this feature to use customized dialogs.
My reproducer :
System::Windows::Forms::OpenFileDialog^ openFileDialog = gcnew System::Windows::Forms::OpenFileDialog();
openFileDialog->AutoUpgradeEnabled = false;
openFileDialog->Title = "Load...";
openFileDialog->AddExtension = true;
openFileDialog->Multiselect = true;
openFileDialog->DefaultExt = "cfg";
System::String^ filterString = "";
filterString += System::String::Format("{0}{1}",
System::String::IsNullOrEmpty(filterString) ? "" : "|",
"Cfg files" + " (*.cfg)|*.cfg");
filterString += System::String::Format("{0}{1}",
System::String::IsNullOrEmpty(filterString) ? "" : "|",
"All files" + " (*.*)|*.*");
openFileDialog->Filter = filterString;
System::Windows::Forms::DialogResult code = openFileDialog->ShowDialog(this);
//select one or a few files
System::Console::WriteLine("selected count = {0}", openFileDialog->FileNames->Length);//returns 0
If you can't reproduce I can send you a minimum project