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

# WdCopySearchOptions

> WdCopySearchOptions

# WdCopySearchOptions

指定复制操作的文件和目录筛选模式。

## 语法

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

### 成员

`_In_z_ includeFilePattern`\
类型：**const char\***

指定要在复制操作中包含哪些文件的 glob 模式（例如 `"*"` 表示包含所有文件，或 `"*.exe;*.dll"` 表示只包含可执行文件和 DLL）。

`_In_z_ excludeFilePattern`\
类型：**const char\***

指定要从复制操作中排除哪些文件的 glob 模式（例如 `"*.pdb"` 表示排除调试符号）。

`_In_z_ excludeDirPattern`\
类型：**const char\***

指定要从复制操作中排除哪些目录的 glob 模式（例如 `".vs;obj"` 表示排除 Visual Studio 目录和生成输出目录）。

`includeFileAttributes`\
类型：**uint64\_t**

一个位掩码，指示文件必须具有哪些文件属性才会被包含在复制中。设置为 `0` 表示不按属性筛选。有关文件属性的更多信息，请参阅[文件属性常量](https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants)。

`excludeFileAttributes`\
类型：**uint64\_t**

一个位掩码，指示哪些文件属性会导致文件从复制中被排除。设置为 `0` 表示不按属性筛选。有关文件属性的更多信息，请参阅[文件属性常量](https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants)。

## 示例

**仅复制 `.exe` 和 `.dll` 文件：**

```cpp theme={null}
WdCopySearchOptions searchOptions = {
    .includeFilePattern = "*.exe;*.dll",
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0
};
```

**从复制中排除名为 `temp` 的目录：**

```cpp theme={null}
WdCopySearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = "temp",
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0
};
```

**仅复制只读或系统文件，并排除隐藏文件：**

```cpp theme={null}
WdCopySearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM,
    .excludeFileAttributes = FILE_ATTRIBUTE_HIDDEN
};
```

<Note>当包含模式和排除模式之间存在冲突时，排除模式优先，该文件将不会被复制。</Note>

## 备注

通过 `searchOptions` 参数将此结构体传递给 [WdRemoteCopy](/reference/remoting/functions/wdremotecopy)，以筛选复制操作中包含的文件和目录。如果为 `searchOptions` 传入 `nullptr`，则所有文件都会被复制而不进行任何筛选。

## 要求

| 要求          | 值                   |
| ----------- | ------------------- |
| **头文件**     | WdRemoteIteration.h |
| **库**       | wdremoteapi.lib     |
| **支持的操作系统** | Windows 11 及更高版本    |
| **支持的体系结构** | x64、ARM64           |

## 另请参阅

* [WdRemoteCopy](/reference/remoting/functions/wdremotecopy)
* [XBOX PC 远程迭代 API](/reference/remoting/remoteiteration_members)


## Related topics

- [WdRemoteCopy](/zh-CN/reference/remoting/functions/wdremotecopy.md)
- [XBOX PC Remote Iteration API](/zh-CN/reference/remoting/remoteiteration_members.md)
- [WdCopyOptions](/zh-CN/reference/remoting/structs/wdcopyoptions.md)
- [WdCopyDirection](/zh-CN/reference/remoting/enums/wdcopydirection.md)
- [WdCopyErrorCallback](/zh-CN/reference/remoting/callbacks/wdcopyerrorcallback.md)
