Access to data or documents area to save info on device

Hiya,

I used to be bale to store my save game data inside a TXT file in the apps Documents directory, but since upgrading to Unity iPhone 1.6 I get the follow error when trying this…

Unhandled Exception: System.UnauthorizedAccessException: Access to the path "/var/mobile/Applications/D82DA52A-7F0C-431D-8DA1-5B6A9E87E521/circuitdefenders.app/Data/SaveGame.txt" is denied.

I get the same if I try the Documents folder too… So, where can we now save our game data?

Also tried…

Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path "/var/mobile/Applications/5B155FED-4B20-46F6-A8FB-9AE18A3D1F2B/circuitdefenders.app/Data/Documents/SaveGame.txt".

and

Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path "/var/mobile/Applications/5B155FED-4B20-46F6-A8FB-9AE18A3D1F2B/circuitdefenders.app/Documents/SaveGame.txt".

Ok, so it looks like now with the *.app appname being appended to the Application.dataPath string now I have to strip it back off myself to get back to the old Application.dataPath string?

Hrm, couldn’t this Application.dataPath var be left alone and a new one added like Application.dataPathFull ?

Seems to break functioning code for no real good reason.

The old way was wrong, and the change is noted, so I don’t have any objection to it.

–Eric

So which folder can be used to store (write/read) files?

Mitec

the applications document folder

Can you please write some example?

the reason is called “Apple guidelines”. This change has been put to the what’s new list and to the documentation. Sorry if that caused you troubles.

no time right now but you can read about it at UIKit | Apple Developer Documentation

Thanks Dreamora, that should help :slight_smile:

Currently ‘Application.dataPath’ for iPhone returns:

/<AppName.app>/Data

I vote that it be changed to return:

/Documents

The way it is now just means you need to do a lot of string manipulation just to get the correct directory.

Your link seems to be broken.

However I found those sources looking for a solution of the same problem.

The blog from where I found the solution

The solution link referred by Harald Vogl