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

# WdDeleteSearchOptions

> WdDeleteSearchOptions

# WdDeleteSearchOptions

Specifies file and directory filter patterns for a delete operation.

**Introduced in:** [RIT 0.0.13-preview](/reference/remoting/release-versions#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](/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](/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](/reference/remoting/functions/wddeleteremotefiles) 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](/reference/remoting/structs/wddeleteoptions), 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](/reference/remoting/functions/wddeleteremotefiles)
* [WdDeleteOptions](/reference/remoting/structs/wddeleteoptions)
* [XBOX PC Remote Iteration API](/reference/remoting/remoteiteration_members)


## Related topics

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