Skip to content

Instantly share code, notes, and snippets.

@CallumWatkins
Last active February 18, 2017 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CallumWatkins/a8c583e6dd67fa472cc6b02640d275e3 to your computer and use it in GitHub Desktop.
Save CallumWatkins/a8c583e6dd67fa472cc6b02640d275e3 to your computer and use it in GitHub Desktop.
Opens a Windows Explorer file/folder search for the specified query, with the option of a location. License: MIT
public void SearchWindowsExplorer(string query, string location = null)
{
if (location != null && !Directory.Exists(location))
{
throw new ArgumentException("Directory does not exist.", "location");
}
string uri = "search:query=" + Uri.EscapeDataString(query) +
(location == null ? string.Empty : "&crumb=location:" + Uri.EscapeDataString(location));
Process.Start(uri);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment