Accessing Files in Resources Folder

Is it possible to access non-text files in the Resources folder in an iPad app?

I can read and write to binary data files in the Resources folder in Unity, but can’t read from them in the app on iPad (haven’t tried writing). I used FileStream and BinaryWriter to create the files, a one-time thing I won’t need to do in the finished app. But I need to read those files at runtime. I used BinaryReader to do that, and it works in Unity. But after installing on the iPad, it cannot find the files. The path I used to write/read the files is:

Application.dataPath + “/Resources/” + fileName + " Data.dat"

I think the files are there, as I’ve used text files in the Resources folder in another app and had no problem reading those. But I used Resource.Load and didn’t have to specify a path name in that app. Can’t do that now because these are not text files (or any standard asset format).

Do I need to use a different path in the built app than in Unity? How can I even tell if the files are there, since I can’t find them in the app bundle?

The Resources folder doesn’t actually exist in a build, except as an abstract concept. The assets get merged into a sharedassets file; you won’t find an actual folder called “Resources” with separate assets in it anywhere.

–Eric

So, you’re saying I can’t save data files in the Resources folder and access them in an app on iPad?

If so, is my only option is to save them as text assets? But converting the data to strings makes the files much larger, which is why I tried binary files to begin with.

no, put them into the stream folder where you also would put movie files in you want to play. that folder will transfer 1:1 as it is

generaly: All you have in the assets folder will either not transfer or as part of a sharedasset bundle, it won’t transfer as standalone file.

You can always use TextAsset.bytes. Just because it’s called “TextAsset” doesn’t mean it has to contain text. :wink:

–Eric

1 Like

Sounds like a solution. I’ll give it a try tomorrow morning when I’m a bit fresher. Any idea what path I would use to get to that folder once it’s inside the app bundle?

you would have to check the dev builds package after compile in xcode to be sure, don’t know it out of head as I only use it for movies.

I don’t see that folder in the app bundle, and I can’t get it to work in Unity either. I placed the iPhoneStreamingAssets folder at the same level as the Assets folder, just like it says in the script reference. So shouldn’t the path be:

FILE_NAME = “…/iPhoneStreamingAssets/” + sourceFile + " Data.dat"

Maybe StreamReader doesn’t take relative paths?

That looks like it’s for loading bytes from a PNG file into textures. My data would not work as a texture. Even so, I’m not sure how I would parse the bytes out of the texture.

No…bytes are just bytes, there are no textures involved. What you do with the bytes is up to you.

–Eric