We help IT Professionals succeed at work.

VS2010, i want to search a file in solution explorer. I couldn't find out. How to?

jazzIIIlove
jazzIIIlove asked
on
Hi there;

In VS2010, i want to search a file in solution explorer. I couldn't find out with Find functionality of VS2010. Maybe, a macro is needed. I don't know.

Can you help me?

Kind regards.
Comment
Watch Question

Commented:
did you try the faithful ctrl + f  also
Edit > quick find

you can choose document, all open documents, project I believe that is what you were asking.

Commented:
Take a look at this link
CERTIFIED EXPERT

Author

Commented:
The issue is that i have ~900 projects in solution explorer, and find is not serving for my need, all i want is that i need to just search and jump on solution explorer.

I couldn't find the solution in the link u provided. Can u point out the solution to read.

Regards.

Commented:
if you would like I could provide you with a linq query you could put into a project that would open each file in a directory and sub directories looking for keywords.
CERTIFIED EXPERT

Author

Commented:
Do it then.
Commented:

Public Sub Main()

        ' Modify this path as necessary.
        Dim startFolder = "c:\program files\Microsoft Visual Studio 9.0\VB\"

        'Take a snapshot of the folder contents
        Dim dir As New System.IO.DirectoryInfo(startFolder)
        Dim fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories)

        Dim searchTerm = "Visual Studio"

        ' Search the contents of each file.
        ' A regular expression created with the RegEx class
        ' could be used instead of the Contains method.
        Dim queryMatchingFiles = From file In fileList _
                                 Where file.Extension = ".htm" _
                                 Let fileText = GetFileText(file.FullName) _
                                 Where fileText.Contains(searchTerm) _
                                 Select file.FullName

        Console.WriteLine("The term " & searchTerm & " was found in:")

        ' Execute the query.
        For Each filename In queryMatchingFiles
            Console.WriteLine(filename)
        Next

        ' Keep the console window open in debug mode.
        Console.WriteLine("Press any key to exit")
        Console.ReadKey()

    End Sub

    ' Read the contents of the file. This is done in a separate
    ' function in order to handle potential file system errors.
    Function GetFileText(ByVal name As String) As String

        ' If the file has been deleted, the right thing
        ' to do in this case is return an empty string.
        Dim fileContents = String.Empty

        ' If the file has been deleted since we took 
        ' the snapshot, ignore it and return the empty string.
        If System.IO.File.Exists(name) Then
            fileContents = System.IO.File.ReadAllText(name)
        End If

        Return fileContents

    End Function

Open in new window

CERTIFIED EXPERT

Author

Commented:
Ok, thanks for the effort, but how can i integraye this code with my solution or how?

Regards.

Commented:
How would you like to integrate this code into your project just as a search screen that searched through files I could make you a sample application.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.