ookii-dialogs-wpf icon indicating copy to clipboard operation
ookii-dialogs-wpf copied to clipboard

Crash for SaveFileDialog when using root directory

Open zappu9x opened this issue 4 years ago • 2 comments

  • Bug crash of VistaFolderBrowserDialog when using root directory path (same for VistaSaveFileDialog when directory is "L:\" (not exist) and default file name is empty)

zappu9x avatar Oct 09 '19 10:10 zappu9x

Hi @zappu9x, thanks for reporting this and for taking the time to submit PR #10.

Could you please add here the steps to reproduce this crash, screenshot, error message (if any), as well more details of your environment (OS, .NET version, NuGet package version, etc.)?

I tested VistaFolderBrowserDialog, VistaSaveFileDialog , and VistaOpenFileDialog, by setting the initial directory to C:\ (also tested C:) and default file name to empty (and null), and didn't see any crash.

Tested on Windows 10, .NET 4.8, latest commit from master as of this writing.

augustoproiete avatar Oct 09 '19 17:10 augustoproiete

Hi @augustoproiete, thanks for reviewing my PR https://github.com/augustoproiete/ookii-dialogs-wpf/pull/10.

Sorry, my response didn't clearly!

You had published 2 libraries ookii-dialogs-wpf and ookii-dialogs-winforms. Thank you very much for your libraries. I think it is same, and i got some issues on ookii-dialogs-winforms so i want to PR both to fix them!

There 2 points i want to update on the PR:

  1. I got different result when using 2 options VistaSaveFileDialog and System.Windows.Forms.SaveFileDialog
  • Option1:
var saveFileDialog = new VistaSaveFileDialog();
  • Option2:
//forceDownLevel using System.Windows.Forms.SaveFileDialog
var saveFileDialog = new VistaSaveFileDialog(true); 
//or saveFileDialog = new SaveFileDialog()

And using the same following code

saveFileDialog.FileName= @"E:\OneDrive";
saveFileDialog.InitialDirectory = @"D:\NewFolder";

Result:

  • System.Windows.Forms.SaveFileDialog: FileName is E:\OneDrive.txt, Folder is D:\NewFolder
  • VistaSaveFileDialog: FileName is OneDrive.txt, Folder is E:\ I think the should be consistency, and result should be same
  1. I got crash if using VistaSaveFileDialog but not with System.Windows.Forms.SaveFileDialog Try to pass not an existing directory like @"L:\" or @"E:\OneDrivexxxx"
var saveFileDialog = new VistaSaveFileDialog();
saveFileDialog.InitialDirectory = @"E:\OneDrivexxxx"; //OneDrivexxxx is not exist directory

They will crash! The below code have a problem when you didn't check exist directory for variable parent!

string folder = Path.GetFileName(_fileNames[0]);
dialog.SetFolder(NativeMethods.CreateItemFromParsingName(parent));
dialog.SetFileName(folder);

Please review this, and if have any question please send to me!

zappu9x avatar Oct 10 '19 07:10 zappu9x