Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
timhereijgers's avatar
2 years ago

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.

1 Reply

Replies have been turned off for this discussion
  • Hi, I am having the exact same problem. Did you find a solution?