I would like to know how I can fetch a phrase within .cs files from a specific folder.
You do not need to develop code, just want to know what functions to use and how to use them. I could not find anything on Google.
I would like to know how I can fetch a phrase within .cs files from a specific folder.
You do not need to develop code, just want to know what functions to use and how to use them. I could not find anything on Google.
You can use the DirectoryInfo classes 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");
}