# How to use GitHub Copilot to optimize file searches

Copilot added safe Windows directory-search prefilters while keeping .NET's managed matching, with wildcard and cross-platform coverage before approval.

Agent: GitHub Copilot (via Copilot coding agent)
Tools: GitHub Copilot, .NET, NtQueryDirectoryFile, GitHub
Category: Software & DevOps
Date: 2026-01-06

Outcome: Copilot added safe Windows directory-search prefilters while keeping .NET's managed matching, with wildcard and cross-platform coverage before approval; the pull request merged into dotnet/runtime main.

## Steps

1. Threaded search expression to Windows enumerator.
2. Identified wildcard patterns safe for OS filtering.
3. Retained managed filter for correctness.
4. Added casing/DOS-wildcard/cross-platform tests.

Human oversight: Human brainstormed approach with Copilot chat and reviewed/merged.

Source: [Copilot (on behalf of stephentoub) on GitHub](https://github.com/dotnet/runtime/pull/122947)

Canonical URL: https://agentsinuse.com/use-cases/github-copilot-to-optimize-file-searches/
