问题描述
如何将多个文件扩展名添加到文件:SSIS 2008 中 Foreach 循环容器中的输入字段.
How could I add multiple file extensions to the Files: input field in the Foreach loop container in SSIS 2008.
我目前以 *.zip
或 .csv
的形式输入,请参阅图片...但它仅在我有一个像 * 这样的值时才有效.zip
I have currently entered as *.zip
OR .csv
see image... but it doesn not work only works if I have one value like *.zip
推荐答案
我不认为你可以在 For each Loop container
中指定两个文件类型扩展名,你应该使用 *.*
并且您可以使用以下步骤过滤特定扩展名:
I don't think you can specify two file type extensions in a For each Loop container
, you should use *.*
and you can filter for a specific extensions by using the following steps:
- 添加一个布尔类型的变量(例如:
User::Flag
) - 在容器内添加一个
script task
,并将Filename
变量标记为Readonly,Flag
变量标记为ReadWrite
- add a Variable of type boolean (ex:
User::Flag
) - add a
script task
inside the container and markFilename
variable as Readonly ,Flag
variable asReadWrite
在脚本里面写如下脚本
Inside the script write the following script
Public Sub Main()
Dim strFile As String = Dts.Variables.Item("Filename").Value.ToString
Select Case IO.Path.GetExtension(strFile).ToLower
Case ".csv", ".zip"
Dts.Variables.Item("Flag").Value = True
Case Else
Dts.Variables.Item("Flag").Value = False
End Select
Dts.TaskResult = ScriptResults.Success
End Sub
向 Script task
输出连接器添加一个表达式,如下所示
Add an expression to the Script task
output connector like shown below
或者您可以通过使用诸如 带正则表达式的 Foreach 文件枚举器
这篇关于如何将多个文件扩展名添加到文件:Foreach 循环容器 SSIS 中的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!