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);
}
Mi programa anterior funciona bien con un solo patrón.Buscar archivos con patrones coincidentes en un directorio C#?
Estoy utilizando el programa anterior para buscar los archivos en un directorio con un patrón coincidente, pero en mi caso tengo varios patrones, así que tengo que pasar varios patrones en la variable string pattern
como una matriz, pero no tengo ninguno idea de cómo puedo manipular esos patrones en Regex.Match.
¿Alguien me puede ayudar?
tipo perfecto, thankss! –