How can I tell Visual Studio to exclude folders from the Find in Files?

We use subversion so we have subfolders named _svn in our solution. Doing a Find in Files returns strings from these subfolders. Is there any way to tell Visual Studio to ignore these files?


Solution 1:

From "Find in Files", in "File Types" or "Look at these file types", you can use:

!*\ExcludeFolder\*

Example:

!*\bin\*;!*\obj\*;!*\.*;!*\ExcludeFolder\*

enter image description here

Solution 2:

What you can do is to setup a set of folders that will be used for searching. In Find and Replace window, on the right hand side of "Look In" input you have a "Choose Search Folders" option where you can setup those sets of folders.
Just remember to turn off "Include sub folders" options if you have added root project folder.
If you don't have hundreds of folders this solution should work.

Solution 3:

Never had an issue with the global find until we moved to Visual Studio 2017 and started with Angular + .net Core applications... (mostly problems with the HUGE node_modules folder being searched)

I found that using the MSBuild exclusion property DefaultItemExcludes is working fine to exclude from global find in Visual studio 2017..

I now by default open up the project file (.csproj) for a new core project in VS2017 and adjust the property as follows to exclude the node_modules (sometimes I add the wwwroot too):

<DefaultItemExcludes>$(DefaultItemExcludes);node_modules\**</DefaultItemExcludes>

See also https://github.com/dotnet/cli/issues/7525 , there they advise to prepend the folders to exclude and seem to use a forward slash instead of backward slash, like this :

<PropertyGroup>
  <DefaultItemExcludes>node_modules/**;$(DefaultItemExcludes)</DefaultItemExcludes>
</PropertyGroup>

Hope this helps anyone experiencing issues with VS2017 global find / search .

Solution 4:

I had this problem when moving to Windows 10 using Visual Studio 2015 and TortoiseSVN. Previously the .svn folders were all hidden so did not appear in search results. To solve this I simply went to the folder properties in Windows Explorer and checked the 'Hidden' attribute for the .svn folder. After refreshing the folder view in Visual Studio the .svn folder no longer appeared and is ignored when using Find!

Set .svn folder attribute to hidden