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

# 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](https://docs.xbox.com/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close.md).

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

## Requirements

**Header:** dstorage\_xs.h

**Library:** dstorage\_xs.lib

**Supported platforms:** XBOX Series consoles

## See also

[IDStorageFactoryX](https://docs.xbox.com/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)\
[DStorage](https://docs.xbox.com/reference/system/dstorage/dstorage_members.md)


## Related topics

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