> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Save

> 指定したコンテナー内の指定した blob (ファイル) にデータを保存します。

# Microsoft.Xbox.Wrappers.XGameSave.Provider.Save

指定したコンテナー内の指定した blob (ファイル) にデータを保存します。

<a id="syntaxSection" />

## 構文

```cpp theme={null}
HRESULT Save(const std::string& containerName,
             const std::string& blobName,
             size_t dataSize,
             const uint8_t* blobData);
```

<a id="parametersSection" />

### パラメーター

*containerName*   \_In\_<br />型: std::string

コンテナーの名前。

*blobName*  \_In\_<br />型: std::string

blob の名前。

*dataSize*   \_In\_<br />型: size\_t

blob に書き込むデータのサイズ。このサイズの上限は最大 16 MB (GS\_MAX\_BLOB\_SIZE) に制限されています。

*blobData*   \_In\_<br />型: uint8\_t\*

blob に書き込むバイトへのポインター。

<a id="retvalSection" />

### 戻り値

型: HRESULT

このメソッドは成功時に **S\_OK** を返し、失敗時は次の HRESULT コードを返します。

* **GS\_INVALID\_CONTAINER\_NAME**
* **GS\_OUT\_OF\_LOCAL\_STORAGE**
* **GS\_UPDATE\_TOO\_BIG**
* **GS\_QUOTA\_EXCEEDED**
* **GS\_HANDLE\_EXPIRED**

<a id="exampleSection" />

## 例

次のコード例は、**Save** 関数の使用方法を示しています。

```cpp theme={null}
using Microsoft::Xbox::Wrappers::GameSave;

std::vector<uint8_t> saveData; // Contains the player's data.

Provider provider = new Provider();

if(SUCCEEDED(provider->Initialize(userHandle, mySCID))
{  
   HRESULT hr = provider->Save("Save_slot_1", "progress", saveData.size(), saveData.data());
   if(FAILED(hr))
   {
      if(hr == E_GS_QUOTA_EXCEEDED)
      {
         // Message that the user must delete saves for this game.
      }
      else if(hr == E_GS_OUT_OF_LOCAL_STORAGE)
      {
         // Message to the user that they have run out of save
         // space on the local device.
      }
      else if(hr == E_GS_UPDATE_TOO_BIG)
      {
         // This is really a development time thing to catch.
         // Your save size was too large for this Save call. Save
         // calls are limited to a maximum size of
         // 16 MB (GS_MAX_BLOB_SIZE).
      }
      else if(hr == E_GS_HANDLE_EXPIRED)
      {
         // You must recreate the provider, and then try again.
      }
      else
      {
         // Log error.
      }
   }
}
```

<a id="remarksSection" />

## 解説

`Provider` クラスの他のメソッドを呼び出す前に、[Initialize](/reference/system/Wrappers/classes/provider/methods/xgamesave_wrapper_provider_initialize) メソッドを呼び出す必要があります。

セーブ ゲーム ラッパーを初期化し、指定したユーザーのすべてのコンテナーを同期するには、[Initialize](/reference/system/Wrappers/classes/provider/methods/xgamesave_wrapper_provider_initialize) を呼び出します。

指定したコンテナー内の指定した blob からデータを読み込むには、[Load](/reference/system/Wrappers/classes/provider/methods/xgamesave_wrapper_provider_load) を呼び出します。

<a id="requirementsSection" />

## 要件

**ヘッダー:** xgamesavewrappers.hpp

**サポート対象プラットフォーム:** Windows、XBOX One ファミリー本体、XBOX Series 本体

<a id="seealsoSection" />

## 関連項目

[Microsoft.Xbox.Wrappers.XGameSave.Provider](/reference/system/Wrappers/classes/provider/xgamesave_wrapper_provider)<br />[XGameSave ラッパー メンバー](/reference/system/Wrappers/xgamesave_wrapper_members)<br />[Load](/reference/system/Wrappers/classes/provider/methods/xgamesave_wrapper_provider_load)


## Related topics

- [Game Save](/ja-jp/build/core-features/common/game-save/index.md)
- [XGameSave](/ja-jp/reference/system/xgamesave/xgamesave_members.md)
- [Game Saves (目次)](/ja-jp/build/core-features/common/game-save/game-saves-toc.md)
- [Game Saves ツール](/ja-jp/build/core-features/common/game-save/game-saves-tools.md)
- [XGameSaveBlob](/ja-jp/reference/system/xgamesave/structs/xgamesaveblob.md)
