Skip to content

[BUG] iOS- UnauthorizedAccessException Occurs in FileStream After Opening and Closing Popup Using ShowPopupAsync() #2617

@AneesFathimaS

Description

@AneesFathimaS

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When we open and close the popup using the ShowPopupAsync method and read a file using the file stream the "Access to the path denied" exception occurs.

Code snippet:
private async void OnPickFileButtonClicked(object sender, EventArgs e)
{
FileResult result = await FilePicker.PickAsync(new PickOptions
{
PickerTitle = "Pick a File",

 });

 if (result == null) return;
 try
 {
     path = result.FullPath;
     await Application.Current.MainPage.ShowPopupAsync(myPopUp);
     using var fs1 = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
     var reader = new StreamReader(fs1);
     exceptionLabel.Text = "No exception";
 }
 catch (Exception ex)
 {
     Console.WriteLine(ex.Message);
     exceptionLabel.Text = ex.Message;
 }

}

Expected Behavior

When we open and close the popup using the ShowPopupAsync method and read a file using the file stream the "Access to the path denied" exception should not occur.

Steps To Reproduce

  1. Run the sample.
  2. Click pick a file button
  3. Popup opens, click outside and close the popup.
  4. The FileStream file read line gets hit and throws an exception as "Access to the path denied".

Link to public reproduction project repository

FileStreamIssue (2).zip

Environment

- .NET MAUI CommunityToolkit:11.2.0
- OS:iOS 16.7.10
- .NET MAUI:9.0.50

Anything else?

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