Page 1 of 1

Noob beginner question: how do you get a file?

Posted: Tue Jan 19, 2021 4:49 pm
by ElChile
Hi everybody,

Sorry for the noob question, but I haven't been able to find in the documentation how to get an es3 file from the directory. Basically what I want to do is to delete/clear a specific file that was created in a previous session. Something like:

Code: Select all

public void ClearData(int _saveSlot)
    { 
        if (ES3.FileExists($"{_saveSlot}_save.es3") )
        {
            ES3File _temp = ES3.GetFile($"{_saveSlot}_save.es3");
            
            _temp.Clear();
        } else
        {
            Debug.LogWarning($"There was not save file for save slot {_saveSlot}");
        }
    }
In the documentation I found the method GetFiles, but that seems to return an array of strings. How can I get the file itself?

Any insight would be super helpful.
Thanks!

Re: Noob beginner question: how do you get a file?

Posted: Tue Jan 19, 2021 5:01 pm
by Joel
Hi there,

You can use ES3.DeleteFile to delete the file from the directory.

All the best,
Joel

Re: Noob beginner question: how do you get a file?

Posted: Wed Jan 20, 2021 1:58 am
by ElChile
Hey Joel!

Thank you that's perfect :D Out of curiosity is there any pro/con to deleting the file versus clearing it? If clearing is preferred what would be the way to do this?

Cheers!
Rafa

Re: Noob beginner question: how do you get a file?

Posted: Wed Jan 20, 2021 8:30 am
by Joel
Hi Rafa,

Clearing the file essentially just deletes the file anyway, but a few extra steps are performed. So ES3.DeleteFile is preferable.

All the best,
Joel

Re: Noob beginner question: how do you get a file?

Posted: Wed Jan 20, 2021 2:13 pm
by ElChile
Gotcha, thanks Joel. And thanks a lot for the quick response!

Cheers,
Rafa