Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace FileSearcher {
- class Program {
- static void Main( string[] args ) {
- if(args.Length != 2) {
- Console.WriteLine("Error: usage is FileSearcher Directory String");
- return;
- }
- string[] filesToSearch = Directory.GetFiles(@args[0], "*.cs", SearchOption.AllDirectories);
- string line;
- foreach (string filePath in filesToSearch) {
- using (StreamReader file = new StreamReader(filePath)) {
- int lineCount = 1;
- while((line = file.ReadLine()) != null) {
- if (line.Contains(args[1])) Console.WriteLine(filePath + " @Line " + lineCount);
- lineCount++;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement