Search code examples
c#wpfexplorerfile-search

How can I programmatically use Windows File Explorer to perform a Search?


We have a folder on our network that we want to search within, including subfolders, from our program. We want to return a list of files whose name contains "String1" or "String2" or "StringN". We would prefer to programmatically open an Explorer window and view all files that match the search results using the native windows file explorer.

Is this possible? How?

Thanks!


Solution

  • You can use the .ms-search file format to express a saved search. If you open this file format it will launch a File Explorer with the search conditions applied.

    If you already have a File Explorer window opened with a search applied, you can save that using the 'save search' button on the ribbon.