简体   繁体   English

打开 Windows 资源管理器并执行搜索

[英]Open Windows Explorer and perform a search

If we want to open Windows Explorer and select a file, we can use the command如果我们想打开 Windows 资源管理器并选择一个文件,我们可以使用命令

System.Diagnostics.Process.Start("explorer.exe", "/select," + @"c:\Folder\file.txt");

Is there a way to open Windows Explorer programmatically and show the results of a search?有没有办法以编程方式打开 Windows 资源管理器并显示搜索结果? For example, as a user I can open Windows Explorer and fill in "*.txt" into search area to list all text files.例如,作为用户,我可以打开 Windows 资源管理器并在搜索区域中填写“*.txt”以列出所有文本文件。

I got it working.我让它工作了。 It was in fact very simple.其实很简单。 Assume I am searching for files with filename containing the term "mat" in folder "C:\temp1".假设我在文件夹“C:\temp1”中搜索文件名包含术语“mat”的文件。 The explorer window has the title "CustomSearch".资源管理器窗口的标题为“CustomSearch”。 It works in Windows 10.它适用于 Windows 10。

string searchLink = "search-ms:displayname=CustomSearch&crumb=filename%3A*mat%20&crumb=location:C%3A%5Ctemp1";
Process.Start(searchLink);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM