Skip to content

Commit

Permalink
fix: FileSavePicker should create target file on GTK and WPF
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 21, 2022
1 parent 6687556 commit d65b9e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using Gtk;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Uno.UI.Runtime.Skia;
Expand Down Expand Up @@ -41,7 +42,11 @@ public FileSavePickerExtension(FileSavePicker owner)
StorageFile? file = null;
if (dialog.Run() == (int)ResponseType.Accept)
{
file = await StorageFile.GetFileFromPathAsync(dialog.Filename);
if (!File.Exists(dialog.Filename))
{
File.WriteAllText(dialog.Filename, "");
}
file = await StorageFile.GetFileFromPathAsync(dialog.Filename);
}

dialog.Destroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -52,6 +53,10 @@ public FileSavePickerExtension(object owner)

if (saveFileDialog.ShowDialog() == true)
{
if (!File.Exists(saveFileDialog.FileName))
{
File.WriteAllText(saveFileDialog.FileName, "");
}
return await StorageFile.GetFileFromPathAsync(saveFileDialog.FileName);
}
return null;
Expand Down

0 comments on commit d65b9e6

Please sign in to comment.