Writing Save Game / Checking space on HD (iOS / PC)

Hi,

First I apologize if that question has been asked already. But I couldn’t find it.
I am making a game and I use a custom save game feature.
I write and encrypt all my data in a file that I read when needed (reload , etc. basic stuff).

What I want to know is how I can make sure there are enough space on the HD to write all the information (right now, I am mostly creating the game for Ipad - but I think this is a more of a general topic - the reason why I did post it here).

What should I do ?

  • Can I reserve some space for my save game ?
  • Should I check if there are enough space and if not, I disable the save game? (letting the user know of course).
  • Are there any other options?

If someone can give me an example on how to do that, I would appreciate it!

Thanks,
Laurel

PS: Sorry for the mistakes if any :slight_smile:

I’m not sure how to do this.

My first thought is to just attempt writing your save file (even if it’s just a bunch of dummy data to take up space) and see if
something like System.IO.File.WriteAllText() throws an exception. If it’s successful, then you have already reserved the space with your dummy file. If you catch an exception, then you can tell the player there’s an error with saving.

I really don’t know what’s considered best practice for stuff like this so I’m interested to see what other people say.

The System.IO.DriveInfo class has a AvailableFreeSpace property, though it doesn’t really work well in Mono. (You can apparently only get the root drive, and the number reported doesn’t seem to have much relationship to the actual amount of free space.)

–Eric

I guess Eric that if you don’t have an answer to my question, it means that the question hasn’t been asked (or answered) on the forum (or mostly)…
Thanks Garth for your help btw :slight_smile:
I am just wondering how the developers are doing to make sure their save game are correctly written to the drive…

I’ve found on the Unity store a package for Android that checks disk space, but not for iOS.

I’ve also found a thread actually checking for disk space on iPad :
http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device
It doesn’t look like c#, and I don’t know how to integrate it to my project …

Any help would be appreciated!

Thanks,
Laurel.