string fileName = ""; string sourcePath = @"C:\vish"; string targetPath = @"C:\SR"; string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, fileName); string pattern = @"23456780"; var matches = Directory.GetFiles(@"c:\vish") .Where(path => Regex.Match(path, pattern).Success); foreach (string file in matches) { Console.WriteLine(file); fileName = System.IO.Path.GetFileName(file); Console.WriteLine(fileName); destFile = System.IO.Path.Combine(targetPath, fileName); System.IO.File.Copy(file, destFile, true); }
My above program works well with one template.
I use the above program to search for files in a directory with an appropriate template, but in my case I have several templates, so I need to pass several templates in the variable string pattern
as an array, but I do not have any idea how I can manipulate this template in Regex.Match.
Can anybody help me?
source share