Skip to content

FileSavePicker auto creates empty file after clicking OK button #5976

@d2phap

Description

@d2phap

Describe the bug

The FileSavePicker creates an empty file without code.

var saveDialog = new FileSavePicker(AppWindow.Id)
{
    DefaultFileExtension = ".xml",
};

saveDialog.FileTypeChoices.TryAdd("TXT", [".txt"]);
saveDialog.FileTypeChoices.TryAdd("JSON", [".json"]);
saveDialog.FileTypeChoices.TryAdd("XML", [".xml"]);

var picker = await saveDialog.PickSaveFileAsync();

// that's it, do nothing here

Steps to reproduce the bug

  1. Run the code above
  2. When the File Save dialog appear, enter non-existing name, such as aaa.txt
  3. Click OK
  4. File aaa.txt is created!!
Image

Expected behavior

The file is not created automatically, the FileSavePicker should only return a full path.

Screenshots

No response

NuGet package version

Windows App SDK 1.8.2: 1.8.251003001

Packaging type

Unpackaged

Windows version

Windows 11 version 24H2 LTSC (26100, June Update)

IDE

Visual Studio 2022

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-File accessTopics related to Microsoft.Windows.Storage.Pickers APIs for selecting files/folders etc.feature proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions