2
I would like to know how I can find a phrase inside files . Cs of a specific folder.
You don’t need to develop code, I just want to know what/what functions to use and how to use them. I couldn’t find anything related on Google.
2
I would like to know how I can find a phrase inside files . Cs of a specific folder.
You don’t need to develop code, I just want to know what/what functions to use and how to use them. I couldn’t find anything related on Google.
3
You can use the classes Directoryinfo and Fileinfo, as follows:
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\projetos\projeto\src");
foreach (FileInfo arquivo in dirInfo.GetFiles("*.cs", SearchOption.AllDirectories))
{
string codigoCSharp = File.ReadAllText(arquivo.FullName);
if (codigoCSharp.Contains("Minha Frase"))
Console.WriteLine("Encontrado");
}
And what it would look like if inside this folder "C: projects src" I had subfolders that I wanted to add to the search?
Utilize SearchOption.AllDirectories
in the second parameter of the method GetFiles
. I edited the answer.
That’s what I was looking for! Thanks for the answer, it was very helpful.
Browser other questions tagged c# filing-cabinet quest
You are not signed in. Login or sign up in order to post.
Do you use any IDE?
– user25930
I’m using Visual Studio 2015.
– Jonathan Barcela