I need a way to list all files that does NOT contain a known text.
The project contains over 1000 files and I only want the ones that does not contain s
You can use the Find in Files feature of notepad++.
Steps:
Here is the loop to get the files list is (searches in .cs
files) (can be optimized):
private void GetFileNamesNotContainingWord(string filePath, string searchDirectoryPath, string notContainingFilePath)
{
string[] lines = File.ReadAllLines(filePath);
List filesList = new List();
foreach (string line in lines)
{
if (!line.StartsWith("\t"))
{
filesList.Add(line.Substring(0, line.LastIndexOf('(')).Trim());
}
}
List notContainedFiles = new List();
foreach (FileInfo file in new DirectoryInfo(searchDirectoryPath).GetFiles("*.cs", SearchOption.AllDirectories))
{
if (!filesList.Contains(file.FullName))
{
notContainedFiles.Add(file.FullName);
}
}
File.WriteAllLines(notContainingFilePath, notContainedFiles.ToArray());
}