1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public class FileDataStore : IDataStore

File data store that implements [IDataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore.md.txt). This store creates a different file for each
combination of type and key. This file data store stores a JSON format of the specified object.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> FileDataStore

## Implements

[IDataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore.md.txt)

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Apis.Util.Store](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.md.txt)

## Assembly

Google.Apis.dll

## Constructors

### FileDataStore(string, bool)

    public FileDataStore(string folder, bool fullPath = false)

Constructs a new file data store. If `fullPath` is `false` the path will be used as relative to
`Environment.SpecialFolder.ApplicationData"` on Windows, or `$HOME` on Linux and MacOS,
otherwise the input folder will be treated as absolute.
The folder is created if it doesn't exist yet.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `folder` | `string` Folder path. |
| `fullPath` | `bool` Defines whether the folder parameter is absolute or relative to `Environment.SpecialFolder.ApplicationData` on Windows, or`$HOME` on Linux and MacOS. |

## Properties

### FolderPath

    public string FolderPath { get; }

Gets the full folder path.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

## Methods

### ClearAsync()

    public Task ClearAsync()

Clears all values in the data store. This method deletes all files in [FolderPath](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_FolderPath).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` |   |

### DeleteAsync\<T\>(string)

    public Task DeleteAsync<T>(string key)

Deletes the given key. It deletes the [GenerateStoredKey(string, Type)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_GenerateStoredKey_System_String_System_Type_) named file in
[FolderPath](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_FolderPath).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `string` The key to delete from the data store. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` |   |

### GenerateStoredKey(string, Type)

    public static string GenerateStoredKey(string key, Type t)

Creates a unique stored key based on the key and the class type.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `string` The object key. |
| `t` | `Type` The type to store or retrieve. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### GetAsync\<T\>(string)

    public Task<T> GetAsync<T>(string key)

Returns the stored value for the given key or `null` if the matching file ([GenerateStoredKey(string, Type)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_GenerateStoredKey_System_String_System_Type_)
in [FolderPath](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_FolderPath) doesn't exist.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `string` The key to retrieve from the data store. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` | The stored object. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type to retrieve. |

### StoreAsync\<T\>(string, T)

    public Task StoreAsync<T>(string key, T value)

Stores the given value for the given key. It creates a new file (named [GenerateStoredKey(string, Type)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_GenerateStoredKey_System_String_System_Type_)) in
[FolderPath](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.FileDataStore.md.txt#Google_Apis_Util_Store_FileDataStore_FolderPath).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `string` The key. |
| `value` | `T` The value to store in the data store. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type to store in the data store. |

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities.md.txt#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)