ookii-dialogs / ookii-dialogs-wpf

Awesome dialogs for Windows Desktop applications built with Microsoft .NET (WPF)
BSD 3-Clause "New" or "Revised" License
1.14k stars 85 forks source link

Crash for SaveFileDialog when using root directory #9

Open zappu9x opened 5 years ago

zappu9x commented 5 years ago
augustoproiete commented 5 years ago

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.

zappu9x commented 5 years ago

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
  2. 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!