FormatException: String was not recognized as a valid Boolean (solved)

Discussion and help for Easy Save 3
Post Reply
doodlinbee
Posts: 3
Joined: Sat Sep 05, 2020 12:53 pm

FormatException: String was not recognized as a valid Boolean (solved)

Post by doodlinbee »

Saving code :

Code: Select all

    public void SaveSequentially(int slot)
    {
        using (ES3Writer writer = ES3Writer.Create(filePath: GetSaveName(slot), settings))
        {
            writer.Write(SceneManager.GetActiveScene().name);
            writer.Write(true);
            writer.Write(false);           
        }
    }
The output :

Code: Select all

{"lighttests"truefalse
}
Loading code :

Code: Select all

    public void LoadSequentially(int slot)
    {
        using (ES3Reader reader = ES3Reader.Create(GetSaveName(slot), settings))
        {
            print(reader.Read<string>());
            print(reader.Read<bool>());
            print(reader.Read<bool>());   
        }
    }
 
When loading, the first read string is ok, but the read bool is not ok. I've got the FormatException: String was not recognized as a valid Boolean

Any ideas ?
Last edited by doodlinbee on Sat Sep 05, 2020 11:04 pm, edited 1 time in total.

User avatar
Joel
Moodkie Staff
Posts: 2973
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException: String was not recognized as a valid Boolean

Post by Joel »

Hi there,

You should only use classes and methods which are documented here. As ES3Writer and ES3Reader are only used internally, they will not work as you expect.

In your case you should follow the instructions here if you want to improve performance:
https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

doodlinbee
Posts: 3
Joined: Sat Sep 05, 2020 12:53 pm

Re: FormatException: String was not recognized as a valid Boolean

Post by doodlinbee »

Hi there,

I don't quite understand the cache system. How to save values in it? Like how to do the equivalent of my OP with the cache?


(I'm looking for performance improvements because i have thousands of keys to store and doing the 'Getting started' way with "ES3.Save" took several minutes to save)

User avatar
Joel
Moodkie Staff
Posts: 2973
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException: String was not recognized as a valid Boolean

Post by Joel »

Hi there,

The equivalent would be:

Code: Select all

var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("myKey1", SceneManager.GetActiveScene().name, GetSaveName(slot), settings);
ES3.Save("myKey2", true, GetSaveName(slot), settings);
ES3.Save("myKey3", false, GetSaveName(slot), settings);
ES3.StoreCachedFile(GetSaveName(slot));
All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

doodlinbee
Posts: 3
Joined: Sat Sep 05, 2020 12:53 pm

Re: FormatException: String was not recognized as a valid Boolean

Post by doodlinbee »

Alright thanks for the help ! :)

Post Reply