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

# IDStorageFactoryX::OpenFile

> IDStorageFactoryX::OpenFile

# IDStorageFactoryX::OpenFile

Opens a file for DirectStorage access.

## Syntax

```cpp theme={null}
HRESULT OpenFile(  
         const WCHAR *path,  
         REFIID riid,  
         void **ppv  
)  
```

### Parameters

*path*   \_In\_z\_\
Type: WCHAR \*

Path of the file to be opened.

*riid*\
Type: REFIID

Specifies the DirectStorage file interface, such as `__uuidof(IDStorageFileX)`.

*ppv*   \_COM\_Outptr\_\
Type: void \*\*

Receives an object representing the opened file.

### Return value

Type: HRESULT

Standard HRESULT error code.

## Remarks

The specified file must be stored on an NVM Express (NVMe) device that is supported by DirectStorage.

A file is implicitly closed when the last reference to the matching `IDStorageFileX` object is released. To explicitly close a file, call [IDStorageFileX::Close](/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close).

For more information, see the "IDStorageFileX" section in [DirectStorage Overview](/build/console-features/storage/directstorage/directstorage-overview).

## Requirements

**Header:** dstorage\_xs.h

**Library:** dstorage\_xs.lib

**Supported platforms:** XBOX Series consoles

## See also

[IDStorageFactoryX](/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx)\
[DStorage](/reference/system/dstorage/dstorage_members)


## Related topics

- [IDStorageFileX](/reference/system/dstorage/interfaces/IDStorageFileX/idstoragefilex.md)
- [IDStorageFileX::Close](/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close.md)
- [IDStorageFileX::GetHandle](/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_gethandle.md)
- [DirectStorage Overview](/build/console-features/storage/directstorage/directstorage-overview.md)
- [IDStorageFactoryX](/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)
