Access to the path '/' is denied. Xamarin Forms

Code:

document.Save(filePath);
Error:

ex {System.UnauthorizedAccessException: Access to the path ‘/’ is denied. —> System.IO.IOException: Permission denied — End of inner exception stack trace — at System.IO.Enumeration.FileSystemEnumerator`1[TResult].CreateDirectoryHandle (System.String pa…}

Screenshot:

Hi Luis,

What is the value of your filePath?
Note, you cannot save your file to the system root.

Instead, please take a look at our Xamarin example, it shows how you can save to your “MyDocuments” folder.

Also, please check the File Storage and Access with Xamarin.Android documentation.
In the “Working with internal storage” section, you can read about the file’s processing (reading and writing) on internal storage.

Regards,
Mario

this method works well in versions smaller than android x, and the directory I use is the one in the example provided for xamarin

Hi Luis,

I’m afraid we were unable to reproduce this issue, we tried with both Android Pie (9.0) and Android Q (10.0).

Can you please send us a project that reproduces your issue so that we can investigate it?

Regards,
Mario

Hello, do you have any news on this topic ?

Hi Moussa,

Please send us a small project that reproduces your issue so that we can investigate it.

Regards,
Mario

Hello here is a small project.

Hi Moussa,

We’re unable to reproduce the issue.

We tested your sample project on the default “Pixel 2 R 11.0 - API 30” emulator and all works fine. No exceptions are thrown.

How exactly are you running the project? Are you testing this on an emulator or a real hardware device?

Regards,
Mario