Skip to main content
timhereijgers
New Participant
July 19, 2023

UnauthorizedAccessException from ReadAllText, but WriteAllText works fine

We're running into some access issues when trying to read and write files from a Meta Quest 2 Unity Application. The strange thing is, it works fine when I write text and I have all the permissions I need, but reading doesn't work.

 

File.WriteAllText("/sdcard/Documents/DeviceSerialNumber.txt", value);

Works fine.


string test = File.ReadAllText("/sdcard/Documents/DeviceSerialNumber.txt");

Gives me an UnauthorizedAccessException.

 

The reason I'm saving in external storage is that we need the data to remain when the application is uninstalled and we need the data to be accessible through other applications.

We already have READ and WRITE permissions through the android manifest. The WritePermission setting is set to External (SDCard), so that should be fine too. We've been stuck on this for days and just can't seem to figure it out.

This topic has been closed for replies.

1 reply

New Participant
April 16, 2024

Hi, I am having the exact same problem. Did you find a solution?