Browse Source

Environment.CurrentDirectory is modified after call to GetOpenFileName | GetSaveFileName call.

pull/828/head
José Manuel Nieto Sánchez 9 years ago
parent
commit
934cc3bafd
  1. 7
      src/Windows/Avalonia.Win32/SystemDialogImpl.cs

7
src/Windows/Avalonia.Win32/SystemDialogImpl.cs

@ -88,9 +88,16 @@ namespace Avalonia.Win32
var pofn = &ofn;
// We should save the current directory to restore it later.
var currentDirectory = Environment.CurrentDirectory;
var res = dialog is OpenFileDialog
? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn))
: UnmanagedMethods.GetSaveFileName(new IntPtr(pofn));
// Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called
Environment.CurrentDirectory = currentDirectory;
if (!res)
return null;
if (dialog?.Filters.Count > 0)

Loading…
Cancel
Save