- Home /
android serialization weird path issue " IsolatedStorageException ", javascript
Hello , i've been struggling with this for days evertyhings works fine on pc but it returns an error on the android device , "IsolatedStorageException " Could not find a part of the path i've been looking for a solution on the forums with no luck , seams like this android serialization subject is not really well covered , well i hope someone can help me with this
// save function
public function Save(){
var MySerializer :XmlSerializer = new XmlSerializer(typeof(Data) );
MyData.SavedHealth =Health;
var MySaveFile :FileStream = new FileStream( Application.streamingAssetsPath+ "/Data.xml",FileMode.OpenOrCreate);
MySerializer.Serialize(MySaveFile,MyData);
MySaveFile.Close();
}
// Open function
public function Open()
{
var MySerializer :XmlSerializer= new XmlSerializer(typeof(Data));
if(File.Exists( Application.streamingAssetsPath+"/Data.xml" ) ){
Debug.Log("File Exits");
var linkstream : WWW ;
if(Application.platform==RuntimePlatform.WindowsEditor)
linkstream = new WWW("file://"+Application.streamingAssetsPath+"/Data.xml" );
else if(Application.platform==RuntimePlatform.Android)
linkstream = new WWW("file://"+ Application.streamingAssetsPath + "/Data.xml" );
while ( ! linkstream.isDone) {}
var RealRootFolder : String = Application.persistentDataPath+"/Data.xml" ;
File.WriteAllBytes(RealRootFolder, linkstream.bytes);
var MySaveFile :FileStream = File.Open(RealRootFolder,FileMode.Open);
MyData= MySerializer.Deserialize(MySaveFile) as Data;
MySaveFile.Close();
Health =MyData.SavedHealth ;
}
Your answer
Follow this Question
Related Questions
ArgumentException: Path is empty while saving data in an XML 0 Answers
"Root Element Missing: XML Exception" when trying to load data from XML file 2 Answers
Unity Serialization with XML Root problem: 'Does Not Denote Valid Type' 0 Answers
Best Way to Store Large Number of GameObjects? 1 Answer
I can't figure out how to use www to copy a file / very confused about porting to android... 0 Answers