Storing large files locally

How do you store large files locally - PlayerPrefs seem limited to 1 MB?

Hi,

have you tried system.IO - StreamWriter function?

Goes like this:

import System.IO;
private var filePath : String;
private var filename= "SavedGame";
private var extension = ".txt";

function Start () {
filePath = Application.dataPath + "/";
print (filePath + filename+ extension);
WriteFile(fileName);
}

function WriteFile(fileName : String) {
var sWrite: StreamWriter = new StreamWriter(filePath + filename + extension);
sWrite.WriteLine("This is a test");
sWrite.WriteLine("We are in level " + Application.loadedLevel);
sWrite.WriteLine("This will be some data");
sWrite.Flush();
sWrite.Close();
}

function ReadFile(fileName : String) {
var sRead = new File.OpenText(filePath + fileName + extension);
var input = "";
while (true) {
input = sRead.ReadLine();
if (input == null) break;
print ("Content: "+ input);
}
sRead.Close();
}

It seems that on FAT32 file systems StreamWriter has file size restriction around 4.2 GB.

Regards.

Correct, use [System.IO] libraries. Here are compatibility notes:

It works out of the box on desktop machines.

It does not work at all in webplayers due to security constraints.

It works on Android if you set up write permissions in the manifest file, see this link

It works on iPhone if you save files to a specifik Documents folder, see this link