ES3.Load

public static T Load<T>(string key, string filePath, T defaultValue, ES3Settings settings)

Description

Loads the value from a file with the given key.

Unless you specify the defaultValue parameter, a KeyNotFoundException or FileNotFoundException will be thrown if the data does not exist. In this case, you can use ES3.KeyExists or ES3.FileExists to check if the data exists before loading.

When loading strings it is recommended to use named parameters to ensure that the correct argument is used. For example this this would cause a FileNotFoundException because it will use the filePath parameter when the defaultValue parameter is intended:

In this case a named parameter can be used to force it to use the correct parameter:

Parameters

key The unique key which identifies the data we're loading.
T [Optional] The type of the data we wish to load. Can be an inherited type.

filePath

[Optional] The relative or absolute path of the file we want to load from.

defaultValue

[Optional] The value we want to return if the file or key does not exist.

settings

[Optional] The settings we want to use to override the default settings.

Returns

The loaded data of type T, or the default value if using the default value parameter and there is no data to load.

Examples