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

# WdEnumRemoteDirectory

> WdEnumRemoteDirectory

Enumerates matching files and directories on a remote Windows device.

**Introduced in:** [RIT 0.0.14-preview](https://docs.xbox.com/reference/remoting/release-versions.md#release-versions).

## Syntax

```cpp theme={null}
HRESULT WD_REMOTE_ITERATION_CALL WdEnumRemoteDirectory(
    _In_z_ const char* remoteDevice,
    _In_opt_z_ const char* remoteFolderPath,
    _In_opt_ const WdRemoteDirectoryOptions* directoryOptions,
    _In_opt_ const WdRemoteDirectorySearchOptions* searchOptions,
    _In_ WdRemoteDirectoryCallback callback,
    _In_opt_ void* context,
    _In_opt_ WdCancellationHandle cancellationHandle
);
```

### Parameters

`remoteDevice`\
Type: **const char\***

The UTF-8 device name or IP address to contact. Resolve any saved default before calling this function.

`remoteFolderPath`\
Type: **const char\***

Optional UTF-8 directory path on the remote device. Null, empty, or `.` selects the common root.

`directoryOptions`\
Type: **const WdRemoteDirectoryOptions\***

Optional common-root, recursion, and metadata settings. Pass `nullptr` for defaults.

`searchOptions`\
Type: **const WdRemoteDirectorySearchOptions\***

Optional file and directory name/attribute filters. Pass `nullptr` for no filtering.

`callback`\
Type: **WdRemoteDirectoryCallback**

The required result or enumeration callback. See Remarks for continuation and lifetime rules.

`context`\
Type: **void\***

Optional caller-owned context passed unchanged to the callback.

`cancellationHandle`\
Type: **WdCancellationHandle**

A cancellation handle created with `WdCreateCancellationHandle`. Where optional, pass `nullptr` if cancellation isn't needed.

### Return value

Type: **HRESULT**

Returns `S_OK` on success; otherwise returns a failure HRESULT. See [Error codes](https://docs.xbox.com/reference/remoting/error-codes.md).

## Remarks

Entries are delivered in traversal-order batches, with UTF-8 paths relative to `remoteFolderPath`. The root itself isn't reported; empty directories are reported. Copy entry data before the callback returns if it is needed later. A failed callback result stops processing and is returned as a failure.

The call is synchronous. A null, empty, or `.` remote path selects the default or named common root. Absolute paths ignore the root alias. `${remoteEnv:NAME}` references use the endpoint process environment. With null options, recursion is disabled and metadata isn't requested.

Use `WdCancelRemoteDirectoryEnumeration` from another thread to request cancellation. Keep the handle open until enumeration returns. Cancellation before work starts returns `S_OK`; after work starts, successful cancellation waits for endpoint acknowledgement. Entries already received form a partial listing. An endpoint without the required directory protocol returns `WD_E_SERVERTOOOLD`.

## Requirements

| Requirement | Value |
| - | - |
| **Header** | WdRemoteIteration.h |
| **Library** | wdremoteapi.lib |
| **NuGet Package** | [Microsoft.GDK.RemoteIterationClientApi](https://aka.ms/GameDevRemoteAPI) |

## See also

* [XBOX PC Remote Iteration API](https://docs.xbox.com/reference/remoting/remoteiteration_members.md)


## Related topics

- [WdCancelRemoteDirectoryEnumeration](https://docs.xbox.com/reference/remoting/functions/wdcancelremotedirectoryenumeration.md)
- [XBOX PC Remote Tools: November 2026 (2611) release notes](https://docs.xbox.com/tools/tools-pc/xbox-pc-remote-tools/release-notes/2611.md)
- [XBOX PC Remote Iteration API](https://docs.xbox.com/reference/remoting/remoteiteration_members.md)
- [WdCancellationHandle](https://docs.xbox.com/reference/remoting/structs/wdcancellationhandle.md)
- [WdRemoteDirectoryEntryType](https://docs.xbox.com/reference/remoting/enums/wdremotedirectoryentrytype.md)
