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

# XPersistentLocalStorageGetPathSize

> XPersistentLocalStorageGetPathSize

# XPersistentLocalStorageGetPathSize

Returns the length, in characters, of the path to the persistent local storage (PLS).

## Syntax

```cpp theme={null}
HRESULT XPersistentLocalStorageGetPathSize(  
         size_t* pathSize  
)  
```

### Parameters

*pathSize*   \_Out\_\
Type: size\_t\*

The length, in characters, of the PLS path.

### Return value

Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

Returns **S\_OK** if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

The return value of this function is used for the *pathSize* parameter of the [XPersistentLocalStorageGetPath](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath) function to return the game-specific PLS path on the device. For more information about PLS, see [Local Storage](/build/console-features/storage/local-storage).

When calling the **XPersistentLocalStorageGetPath** function, allocate at least as many characters for the *path* parameter of **XPersistentLocalStorageGetPath** as the number specified in the value returned in the *pathSize* parameter of this function; failure to do so will cause an error.

The following example illustrates how to use the **XPersistentLocalStorageGetPathSize** and **XPersistentLocalStorageGetPath** functions to get the PLS path for your game.

```cpp theme={null}
// Confirm that all of the features needed to run asynchronous tasks on 
// task queues are available.
LPCSTR Game::CheckPLSPath()
{
    // Confirm the length of the path to the local storage folder.
    LPCSTR returnPath = "";
    size_t pathSize;
    if (SUCCEEDED(XPersistentLocalStorageGetPathSize(&pathSize)))
    {
        char * path = new char[pathSize];
        size_t * pathUsed = new size_t;
        if (path != nullptr)
        {
            // Get the path to the local storage folder.
            if (SUCCEEDED(XPersistentLocalStorageGetPath(pathSize, path, pathUsed))) 
            {
                // Just to be safe, copy the bytes used in the buffer 
                // to a separate string.
                char * actualPath = new char[*pathUsed];
                strncpy(actualPath, path, *pathUsed);
                returnPath = actualPath;
            }
        }
    };

    return returnPath;
}
```

## Requirements

**Header:** XPersistentLocalStorage.h

**Library:** xgameruntime.lib

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

## Conceptual documentation

* [Local storage on XBOX console](/build/console-features/storage/local-storage)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XPersistentLocalStorageGetPath](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath)\
[XPersistentLocalStorage](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members)\
[How to use the new MicrosoftGame.config file](/build/core-features/common/game-config/MicrosoftGameConfig-toc)


## Related topics

- [XPersistentLocalStorageGetPath](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath.md)
- [XPersistentLocalStorage](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members.md)
- [Unity C# API wrappers for the GDK](/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XPersistentLocalStorageGetSpaceInfo](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetspaceinfo.md)
- [XPersistentLocalStorageMountForPackage](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragemountforpackage.md)
