Limit search to specified Folders or File Types in Visual Studio?

Visual StudioSearchVisual Studio-2008Find

Visual Studio Problem Overview


Is there a way to limit a search (via the "Find and Replace" dialog) in Visual Studio to specified folders or file types?

Visual Studio Solutions


Solution 1 - Visual Studio

Yes, in the find/replace window you can:

  • specify the file types in the "Look at these file types" option
  • and choose the folders in the ... button of the "Look in" option.

Find and Replace Window

Solution 2 - Visual Studio

I can't believe this issue still exists in VS2015. We have a solution explorer folder tree. Why is "Current Selected Folder" not an option in the drop down. The "..." doesn't default to starting in the solution folder, I have to browse across the network to t the share, then drill down through all the folders to get at a folder that is ALREADY right there and selected in the solution explorer. Dreamweaver has had this functionality for its search for at least a decade (maybe longer).

Solution 3 - Visual Studio

  1. Click Find in Files
  2. Choose search folders three dots button "..."
  3. Choose desired folder
  4. Verify folder name and click desired action

Click Find in Files

Choose search folders

Choose desired folder Verify folder name and click desired action

Solution 4 - Visual Studio

Fastest folder search in VS:

As said in other answers, there is no immediate way to limit your search to a given folder within the current solution. (There are at least 3 feature requests for this in visualstudio.uservoice.com that have all been closed for lack of upvotes.)

But here is the fastest workaround that I could find.
Works without leaving VS and with keystrokes only (no mouse action required):

  • In Solution Explorer select the folder to search within.
  • Press Ctrl-C (copies folder path to clipboard).
  • Press Ctrl-Shift-F to open "Find in Files".
  • Enter your search term, then press Tab to forward the cursor to the "Look in" field.
  • Press Ctrl-V to paste in the folder path from clipboard.

Solution 5 - Visual Studio

2020-Update: Actually you can select the folder (also the current directory with two clicks) and define file types in Microsoft Visual Studio Professional 2019, Version 16.7.5

Select current directory in find and replace dialog

Solution 6 - Visual Studio

While the Choose Search Folders works, it could be much better. I would really like to choose folders to exclude as well as include because sometimes folders are nested. You may want a folder but only some of the subfolders.

But by far the worst inconvenience is that it is not stored with the solution. If I go to the trouble of defining a search, and close VS, then reopen, I have to define it all over.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBryanView Question on Stackoverflow
Solution 1 - Visual StudioFabio Vinicius BinderView Answer on Stackoverflow
Solution 2 - Visual StudioWolfieView Answer on Stackoverflow
Solution 3 - Visual StudioManirajSSView Answer on Stackoverflow
Solution 4 - Visual StudioJpsyView Answer on Stackoverflow
Solution 5 - Visual StudioAdrian DymorzView Answer on Stackoverflow
Solution 6 - Visual StudioWray SmallwoodView Answer on Stackoverflow