Skip to content

iOS: Unable to create file within app sandbox #19569

@dmirmilshteyn

Description

@dmirmilshteyn

Describe the bug

When trying to create a file within a directory that is part of the app (such as the Documents directory), it returns a null file and the file is not created. This happens only when using IStorageFolder::CreateFileAsync. Creating the file using regular File.Create calls works successfully.

I suspect this is because of this check. StartAccessingSecurityScopedResource will return false if the user is unable to access the resource OR if the resource is already in the app sandbox (such as the documents folder).

Other file operations succeed because they don't check the result of StartAccessingSecurityScopedResource.

To Reproduce

  • Access the app documents folder
  • Attempt to create a test file within that directory
  • The test file will not be created
var documents = await storageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents);
var test = await documents.CreateFileAsync("test.txt");
// test is null, it should have been created

Expected behavior

No response

Avalonia version

11.3.4

OS

iOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions