Es3.Load<string> exception

Discussion and help for Easy Save 3
Post Reply
RogueProgrammer
Posts: 2
Joined: Mon Jan 15, 2024 10:01 pm

Es3.Load<string> exception

Post by RogueProgrammer »

I have no issues using the ES3.Load for a number of different data types however, when I try and use it to load in a string that was saved, I get an exception. It appears it is trying to use the Key as the filename for some reason.

If I check to see if the key exists and then load it, it succeeds. However if I call Load<string> with a default string, it gets an exception and when I trace into the ode it is trying to open a save file with the name of the strings key. So if I call the string "test" it would try and open a save file named test.

Here is an example showing how it works and how it fails:

Code: Select all

            string SupportGUID = "";
            
            // this works
            if (ES3.KeyExists("SupportGUID"))
            {
                SupportGUID = ES3.Load<string>("SupportGUID");
            }

            // This fails with an exception because it tries to open a save file named "SupportGUID"
            SupportGUID = ES3.Load<string>("SupportGUID", "");
From the documentation, it seems I am calling the Load<string> correctly. So what am I doing wrong?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Es3.Load<string> exception

Post by Joel »

Hi there,

The second parameter to the ES3.Load method in that case would be the filename, not the default value. If you want to specify the defaultValue parameter you should use a named parameter. I.e.

string str = ES3.Load<string>(key, defaultValue: " ");

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RogueProgrammer
Posts: 2
Joined: Mon Jan 15, 2024 10:01 pm

Re: Es3.Load<string> exception

Post by RogueProgrammer »

Thank you! I must have missed that in the doc.
Post Reply