![]() ![]() If the file has been deleted since we took Keep the console window open in debug mode.Ĭonsole.WriteLine("Press any key to exit") Let fileText = GetFileText(file.FullName)Ĭonsole.WriteLine("The term \"\" was found in:", searchTerm) įoreach (string filename in queryMatchingFiles) could be used instead of the Contains method. A regular expression created with the RegEx class IEnumerable fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories) for all folders under the specified path. This method assumes that the application has discovery permissions System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(startFolder) String startFolder = files\Microsoft Visual Studio 9.0\" For more information, see How to combine LINQ queries with regular expressions (C#). However, more complex types of pattern matching can be performed with a regular expression. A simple string search is performed in this example. This type of technique could be used to create indexes or reverse indexes of the contents of a directory tree. This example shows how to query over all the files in a specified directory tree, open each file, and inspect its contents.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |