A customer just had this error with our application, which basically happens when calling ShowDialog on a Microsoft.Win32.SaveFileDialog. The complete stack trace is the following:
System.InvalidOperationException: 'My File.xlsx' is not a valid file name. at Microsoft.Win32.SaveFileDialog.RunFileDialog(OPENFILENAME_I ofn) at Microsoft.Win32.FileDialog.RunLegacyDialog(IntPtr hwndOwner) at Microsoft.Win32.FileDialog.RunDialog(IntPtr hwndOwner) at Microsoft.Win32.CommonDialog.ShowDialog(Window owner) at (our code here)
The code that shows the dialog is pretty standard:
var dialog = new SaveFileDialog
{
Filter = "Excel files (.xlsx)|*.xlsx",
FileName = "My File.xlsx",
};
if (dialog.ShowDialog() == true)
{
result = dialog.FileName;
}
else
{
result = null;
}
Our application is a WPF application running on the .NET 4.0 framework. The code works fine on my machine as well as on every other customer's machine, but it throws this error for this particular customer. I tried doing some research about this, but I did not find anything useful as to what might be causing it. The file name does seem perfectly valid. Any ideas?