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

# WdDeleteSearchOptions

> Reference for WdDeleteSearchOptions, which sets include and exclude patterns and attribute filters that select items to delete with WdDeleteRemoteFiles.

Specifies file and directory filter patterns for a delete operation.

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

## Syntax

```cpp theme={null}
struct WdDeleteSearchOptions
{
    const char* includeFilePattern;
    const char* excludeFilePattern;
    const char* excludeDirPattern;
    uint64_t includeFileAttributes;
    uint64_t excludeFileAttributes;
    uint64_t includeDirAttributes;
    uint64_t excludeDirAttributes;
};
```

### Members

`includeFilePattern`\
Type: **const char\***

Includes files that match the specified names. The wildcard characters `*` and `?` are supported, and a list of patterns can be separated by a semicolon (`;`). The default is `nullptr`, which includes everything.

`excludeFilePattern`\
Type: **const char\***

Excludes files that match the specified names. The wildcard characters `*` and `?` are supported, and a list of patterns can be separated by a semicolon (`;`). The default is `nullptr`, which excludes no files.

`excludeDirPattern`\
Type: **const char\***

Excludes directories that match the specified names, not paths. The wildcard characters `*` and `?` are supported. The default is `nullptr`, which excludes no directories from being deleted.

`includeFileAttributes`\
Type: **uint64\_t**

Includes files for which any of the specified file attributes are set. The supported values are `FILE_ATTRIBUTE_READONLY`, `FILE_ATTRIBUTE_ARCHIVE`, `FILE_ATTRIBUTE_SYSTEM`, and `FILE_ATTRIBUTE_HIDDEN`. The default is `0`, which includes all attributes. For additional information on file attributes check [File Attribute Constants](https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants).

`excludeFileAttributes`\
Type: **uint64\_t**

Excludes files for which any of the specified file attributes are set. The supported values are `FILE_ATTRIBUTE_READONLY`, `FILE_ATTRIBUTE_ARCHIVE`, `FILE_ATTRIBUTE_SYSTEM`, and `FILE_ATTRIBUTE_HIDDEN`. The default is `0`, which excludes no attributes. For additional information on file attributes check [File Attribute Constants](https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants).

`includeDirAttributes`\
Type: **uint64\_t**

Includes directories for which any of the specified file attributes are set. The supported values are `FILE_ATTRIBUTE_READONLY`, `FILE_ATTRIBUTE_ARCHIVE`, `FILE_ATTRIBUTE_SYSTEM`, and `FILE_ATTRIBUTE_HIDDEN`. The default is `0`, which includes all attributes.

`excludeDirAttributes`\
Type: **uint64\_t**

Excludes directories for which any of the specified file attributes are set. The supported values are `FILE_ATTRIBUTE_READONLY`, `FILE_ATTRIBUTE_ARCHIVE`, `FILE_ATTRIBUTE_SYSTEM`, and `FILE_ATTRIBUTE_HIDDEN`. The default is `0`, which excludes no attributes.

## Examples

**Delete only `.pdb` and `.log` files:**

```cpp theme={null}
WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = "*.pdb;*.log",
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0,
    .includeDirAttributes = 0,
    .excludeDirAttributes = 0
};
```

**Delete everything except a save data directory:**

```cpp theme={null}
WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = "SaveData",
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0,
    .includeDirAttributes = 0,
    .excludeDirAttributes = 0
};
```

**Delete archived files, but preserve read-only files and hidden directories:**

```cpp theme={null}
WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = FILE_ATTRIBUTE_ARCHIVE,
    .excludeFileAttributes = FILE_ATTRIBUTE_READONLY,
    .includeDirAttributes = 0,
    .excludeDirAttributes = FILE_ATTRIBUTE_HIDDEN
};
```

> [!NOTE]
>
> \
> When there is a conflict between include and exclude patterns, the exclude pattern takes precedence and the item will not be deleted.

## Remarks

Pass this structure to [WdDeleteRemoteFiles](https://docs.xbox.com/reference/remoting/functions/wddeleteremotefiles.md) via the `searchOptions` parameter to filter which files and directories are selected for deletion. If `nullptr` is passed for `searchOptions`, all items are included with no filtering.

These options apply only when `remoteFolderPath` resolves to a folder. They are ignored when `remoteFolderPath` resolves to a single file.

A filtered delete that leaves items behind preserves the root folder even when `deleteRootFolder` is set to `true` in [WdDeleteOptions](https://docs.xbox.com/reference/remoting/structs/wddeleteoptions.md), because the folder is removed only if it is left empty.

## Requirements

| Requirement | Value |
| - | - |
| **Header** | WdRemoteIteration.h |
| **Library** | wdremoteapi.lib |
| **Supported OS** | Windows 11 and later |
| **Supported architectures** | x64, ARM64 |

## See also

* [WdDeleteRemoteFiles](https://docs.xbox.com/reference/remoting/functions/wddeleteremotefiles.md)
* [WdDeleteOptions](https://docs.xbox.com/reference/remoting/structs/wddeleteoptions.md)
* [XBOX PC Remote Iteration API](https://docs.xbox.com/reference/remoting/remoteiteration_members.md)


## Related topics

- [WdDeleteOptions](https://docs.xbox.com/reference/remoting/structs/wddeleteoptions.md)
- [WdDeleteRemoteFiles](https://docs.xbox.com/reference/remoting/functions/wddeleteremotefiles.md)
- [XBOX PC Remote Iteration API](https://docs.xbox.com/reference/remoting/remoteiteration_members.md)
- [WdCopySearchOptions](https://docs.xbox.com/reference/remoting/structs/wdcopysearchoptions.md)
- [XBOX PC Remote (wdRemote.exe)](https://docs.xbox.com/tools/tools-pc/commandlinetools/gr-wdRemote.md)
