SSIS Converting wildcard characters file pattern to regex

Sometimes we need to use wildcard characters in ours SSIS solutions to define a search pattern. The SSIS has total support to wildcard, and you can keep using it to find files in a local file system, but how can we use it in a C# script for an FTP directory? The best way that I have found was using regex.

//Converting FilePattern to regex language
Regex mask = new Regex(‘^’ + Dts.Variables[“FilePattern“].Value.ToString().Replace(“.”, “[.]“).Replace(“*”, “.*”).Replace(“?”, “.”) + ‘$’, RegexOptions.IgnoreCase);

The FilePattern is my variable with the file name pattern.


  • FileParttern [wildcard characters]: FinancialsData*.xlsx
  • FileParttner [Regex]: ^FinancialsData.*[.]xlsx$

You can use the regex tester ( to check your pattern.


Deixe uma resposta

O seu endereço de email não será publicado Campos obrigatórios são marcados *

Você pode usar estas tags e atributos de HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>