Noob beginner question: how do you get a file?

Discussion and help for Easy Save 3
Post Reply
ElChile
Posts: 8
Joined: Thu Jan 07, 2021 2:15 pm

Noob beginner question: how do you get a file?

Post 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!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

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

Post by Joel »

Hi there,

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

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
ElChile
Posts: 8
Joined: Thu Jan 07, 2021 2:15 pm

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

Post 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
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

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

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
ElChile
Posts: 8
Joined: Thu Jan 07, 2021 2:15 pm

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

Post by ElChile »

Gotcha, thanks Joel. And thanks a lot for the quick response!

Cheers,
Rafa
Post Reply