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);
}
Mój powyższy program działa dobrze z jednym wzorem.Znajdź pliki z pasującymi wzorcami w katalogu C#?
Używam powyższego programu do znajdowania plików w katalogu z pasującym wzorcem, ale w moim przypadku mam wiele wzorców, więc muszę przekazać wiele wzorca w zmiennej string pattern
jako tablicy, ale nie mam żadnych pomysł jak mogę manipulować tymi wzorami w Regex.Match.
Czy ktoś może mi pomóc?
idealny Koleś, thankss! –