> ## 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.

# XGameSaveEnumerateContainerInfoByName

> XGameSaveEnumerateContainerInfoByName

# XGameSaveEnumerateContainerInfoByName

Retrieves the container info for an **XGameSaveProvider**. Providing a prefix will cause the function to return only words which have that same prefix.

## Syntax

```cpp theme={null}
HRESULT XGameSaveEnumerateContainerInfoByName(  
         XGameSaveProviderHandle provider,  
         const char* containerNamePrefix,  
         void* context,  
         XGameSaveContainerInfoCallback* callback  
)  
```

### Parameters

*provider*   \_In\_\
Type: XGameSaveProviderHandle

**XGameSaveProvider** containing the [XGameSaveContainerInfo](/reference/system/xgamesave/structs/xgamesavecontainerinfo).

*containerNamePrefix*   \_In\_opt\_z\_\
Type: char\*

A prefix that will be used to search the list of containers for matching container names.

*context*   \_In\_opt\_\
Type: void\*

Pointer that will be passed into the callback function.

*callback*   \_In\_\
Type: XGameSaveContainerInfoCallback\*

The callback function to run for every container that matches the prefix, return false to stop the enumeration. Use this function to collect the [XGameSaveContainerInfo](/reference/system/xgamesave/structs/xgamesavecontainerinfo).

### Return value

Type: HRESULT

Function result.

## Remarks

Use this function to inspect what containers are available for a user. This may include data that is needed to show in UX. Enumerating this set will not cause a sync for a SyncOnDemand provider and will allow the caller to actually inspect the sync status via the needsSync field of [XGameSaveContainerInfo](/reference/system/xgamesave/structs/xgamesavecontainerinfo). Any read of blob data or usage of an update context on a container that has *needsSync* set to true will force a sync and could potentially return various sync errors. You may use [XGameSaveEnumerateContainerInfo](/reference/system/xgamesave/functions/xgamesaveenumeratecontainerinfo) if you do not need to specify a prefix for your enumerated containers. [XGameSaveEnumerateContainerInfo](/reference/system/xgamesave/functions/xgamesaveenumeratecontainerinfo) will return the full list of available containers.

```cpp theme={null}
// Enumerate Container List by prefix, if no prefix is supplied it is 
// the same as calling XGameSaveEnumerateContainerInfo. 
// NOTE: this should be safe to call from a time critical thread 
// but the we are at the mercy of the callback. 
void Sample::_EnumerateContainerInfoByName(const char* prefix) 
{ 
    HRESULT hr = XGameSaveEnumerateContainerInfoByName(_provider, prefix, this, 
        [](const XGameSaveContainerInfo* container, void* context) 
    { 
        auto self = reinterpret_cast<Sample*>(context); 
        self->_UpdateContainerList(container); 
        return true; 
    }); 
    if (FAILED(hr)) 
    { 
        _HandleContainerErrors(prefix, hr); 
    } 
  
} 
```

## Requirements

**Header:** XGameSave.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XGameSave](/reference/system/xgamesave/xgamesave_members)\
[XGameSaveEnumerateContainerInfo](/reference/system/xgamesave/functions/xgamesaveenumeratecontainerinfo)\
[Debugging Game Saves](/build/core-features/common/game-save/game-saves-debugging)


## Related topics

- [XGameSaveEnumerateContainerInfo](/reference/system/xgamesave/functions/xgamesaveenumeratecontainerinfo.md)
- [XGameSaveContainerInfoCallback](/reference/system/xgamesave/functions/xgamesavecontainerinfocallback.md)
- [XGameSaveContainerInfo](/reference/system/xgamesave/structs/xgamesavecontainerinfo.md)
- [XGameSaveGetContainerInfo](/reference/system/xgamesave/functions/xgamesavegetcontainerinfo.md)
- [XGameSave API overview](/build/core-features/common/game-save/xgamesave.md)
