- Home /
C# Serialization error on Mobile using FileStream
Hey Guys,
So I have a SaveGame file that I want to use to Save/Load my game. When I use it in the Editor it works like a charm, but when I tested it on device, it crashed on the FileStream. Looks like I can't use it on Android at least. Somebody suggested a TextAsset instead of the filestream and save it as a .bytes extension. The problem with this is that I can only read a TextAsset, and cannot modify it (correct me if I'm wrong though). Unfortunatly, I have to write my savegame also. Does somebody have a simple solution to be able to save/load serialized data without a FileStream ?
Thanks a lot for your time and have a great day !
Claude
Answer by MartinCA · Sep 08, 2013 at 09:02 PM
Never had any problems using file streams on iOS/Android.
We always use BinaryWriter, but it implements some sort of stream internally so shouldn't be a problem there.
Most likely this is a file system access restriction. Apps on mobile are executed from the installation folder to which the app doesn't have write permissions, try saving to Application.persistentDataPath, it is a unity property which should always resolve to a correct write able path according to platform.
Sorry for the brief response, on vacation posting from mobile :)
Thanks a lot $$anonymous$$artin, it was my error, I was using Application.datapath ins$$anonymous$$d of Application.persistentdatapath. Changed it and it worked like a charm ! Thanks a lot :)
Your answer
Follow this Question
Related Questions
File saving error 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# Serialization is working fine in Unity but not on Android 2 Answers
Deserialize a static class C# 1 Answer