我需要更改此存在检查以在User :: FileName上使用通配符

问题描述

几个月前,我从billinkc那里获得了一些很棒的帮助,涉及SSIS包中的文件存在检查。效果很好,但是我需要对通配符做同样的事情。 billinkc或其他任何人可以帮助修改它以在User :: FilePath中进行文件名LIKE * DoR的存在检查吗?

public void Main()
  {
        // Todo: Add your code here
        string filepath = System.IO.Path.Combine(Dts.Variables["User::FilePath"].Value.ToString(),Dts.Variables["User::FileName"].Value.ToString());
        if (System.IO.File.Exists(filepath))
        {
            Dts.Variables["User::FileExists"].Value = true;
        }


        // Log the state of all our SSIS variables
        bool fireAgain = false;
        string message = "{0}::{1} : {2}";
        foreach (var item in Dts.Variables)
        {
            Dts.Events.Fireinformation(0,"SCR Echo Back",string.Format(message,item.Namespace,item.Name,item.Value),string.Empty,ref fireAgain);
        }

        // Log the file path that was built
        Dts.Events.Fireinformation(0,"local","filepath",filepath),ref fireAgain);

        Dts.TaskResult = (int)ScriptResults.Success;

  }

解决方法

您可以将代码简化为:

user@MacBook-Air-4 [12:54:04] [~/Desktop/my_project/extra_exchange] [develop]
-> % git push origin HEAD
Enumerating objects: 13,done.
Counting objects: 100% (13/13),done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7),done.
Writing objects: 100% (7/7),670 bytes | 670.00 KiB/s,done.
Total 7 (delta 5),reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5),completed with 5 local objects.
To https://github.com/Toshiyuki023Hori/extra_exchange.git
   b0b58fa..8951723  HEAD -> develop
user@MacBook-Air-4 [12:54:24] [~/Desktop/my_project/extra_exchange] [develop]
-> % gs
On branch develop
nothing to commit,working tree clean

我认为您需要切换到.Net Framework4。您可以通过更改项目属性来实现。右键单击解决方案资源管理器上的无法识别的长名称,然后单击属性。

enter image description here