Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Saves data to the specified blob (file) within the specified container.
Syntax
HRESULT Save(const std::string& containerName,
const std::string& blobName,
size_t dataSize,
const uint8_t* blobData);
Parameters
containerName _In_
Type: std::string
The name of the container.
blobName _In_
Type: std::string
The name of the blob.
dataSize _In_
Type: size_t
The amount of data to write to the blob. This size is limited to a maximum of 16 MB (GS_MAX_BLOB_SIZE).
blobData _In_
Type: uint8_t*
A pointer to the bytes to write to the blob.
Return value
Type: HRESULT
This method returns S_OK upon success, and the following HRESULT codes upon failure:
- GS_INVALID_CONTAINER_NAME
- GS_OUT_OF_LOCAL_STORAGE
- GS_UPDATE_TOO_BIG
- GS_QUOTA_EXCEEDED
- GS_HANDLE_EXPIRED
Example
The following code example demonstrates how to use the Save function.
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.
}
}
}
Remarks
You must call the Initialize method before you can call any other method from the Provider class.
To intialize the save game wrapper, and synchronizes all of the containers for the specified user, call Initialize.
To load the data from the given blob, from within the specified container, call Load.
Requirements
Header: xgamesavewrappers.hpp
Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles
See also
Microsoft.Xbox.Wrappers.XGameSave.Provider
XGameSave wrapper members
Game saves simplified wrapper
Load