# Data Management

{% hint style="info" %}
You may need to code a bit differently if you have background task enabled. See [Understanding Background Save & Load](/esave/scripting/understanding-background-save-and-load.md)
{% endhint %}

## Getting the Save File

The first step to saving data is getting the save file. This can be done by getting the save file setup component first, which will give you access to the save file with `SaveFileSetup.GetSaveFile`. This can be skipped if you already have a save file reference.

```csharp
saveFileSetup = GetComponent<SaveFileSetup>();
saveFile = saveFileSetup.GetSaveFile();
```

It's recommended to use this code in Awake or Start.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://espergames.gitbook.io/esave/scripting/saving-and-loading/data-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
