[Solved] Regular expression to search for files and folders [closed]


Here shows you how to use regex in C#.
You could always just loop the directory that you’re looking in and check the file names instead of making a regex. (You’ll need to use System.IO)

Perhaps something like this?

string [] fileEntries = Directory.GetFiles(targetDirectory); 
Regex regex = new Regex("target file name");
Match match = regex.Match(string.Join(" ", fileEntries););
if (match.Success)
{
    Console.WriteLine(match.Value);
}

solved Regular expression to search for files and folders [closed]