Explorar el Código

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

José Manuel Nieto Sánchez hace 9 años
padre
commit
934cc3bafd
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      src/Windows/Avalonia.Win32/SystemDialogImpl.cs

+ 7 - 0
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)