Search code examples
c#windows-searchfile-search

Searching for files containing specified strings in C#


I am trying to write a WinForms app, that allows searching for a files, that contain a string written in textbox ( press WIN+F and you understand ;) ) in this app, there is a list of files and directories, that must be searched for this string

those files are mostly .doc and .xls i think, that searching in doc may be easier, but in Excel files, cells can have different encodings i've tried to "read" those files, by opening them in Notepad++, and i found that cells with only latin characters were easy to find, but those with polish characters, had a two byte encoding

in windows built in search, there was no problem, it was able to tell, that in some test files there is my string that contains polish special characters

so my question basically is, if there is a method to use this windows built-in search engine for my app ( as i wrote, i need to find only filenames ), or maybe you have any other idea, how i can write a simple multi-file search ?


Solution

  • You probably want to use the Windows Search SDK.