申し訳ありませんが、急いでいます。これがスクリプトのスナップショットです。うまくいけば役に立ちます。
このパッケージは、仕様に準拠するファイルのフォルダーをスキャンし、コントロールをデータ フローに渡します。
代替テキスト http://img395.imageshack.us/img395/8531/dynafilecontrolflowms9.jpg
制御フロー、http://img395.imageshack.us/img395/8531/dynafilecontrolflowms9.jpg
代替テキスト http://img104.imageshack.us/img104/2010/dynafileforeachij5.jpg
For Each ループ プロパティ: http://img104.imageshack.us/img104/2010/dynafileforeachij5.jpg
代替テキスト http://img164.imageshack.us/img164/7614/dynafilefilesystemyj1.jpg
ファイル システムのプロパティ、http://img164.imageshack.us/img164/7614/dynafilefilesystemyj1.jpg
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO
Public Class ScriptMain
Public Sub Main()
Dim Ext As String = ".txt"
Dim Path As String = ".\" 'must get from package variable to be more dynamic
Dim FileNames() As String = Directory.GetFiles(Path, "CC*" + Ext, SearchOption.TopDirectoryOnly)
Dim ValidFileNames As New Collection
For Each FileName As String In FileNames
Dim FileDate As String = FileName.Substring(Len(Path) + 2) 'first 2 letter is already "CC"
If Not IsYmd(FileDate.Substring(0, Len(FileDate) - Len(Ext))) Then Continue For
ValidFileNames.Add(FileName)
Next
Dts.Variables("FileNames").Value = ValidFileNames
Dts.TaskResult = Dts.Results.Success
End Sub
Private Function IsYmd(ByVal Test As String) As Boolean
If Len(Test) <> 6 Then Return False
Dim Year As String = Left(Test, 2)
Try
If CStr(2000 + CInt(Year)) <> "20" + Year Then Return False
Catch ex As Exception
Return False
End Try
Dim Month As String = Mid(Test, 3, 2)
Try
If CInt(Month) < 1 Then Return False
If CInt(Month) > 12 Then Return False
Catch ex As Exception
Return False
End Try
Dim Day As String = Right(Test, 2)
Dim FirstOfMonth As String = "20" + Year + "/" + Month + "/01"
Dim EndOfMonth As Integer = DateAndTime.Day(DateAndTime.DateAdd(DateInterval.Day, -1, _
DateAndTime.DateAdd(DateInterval.Month, 1, CDate(FirstOfMonth))))
Try
If CInt(Day) < 1 Then Return False
If CInt(Day) > EndOfMonth Then Return False
Catch ex As Exception
Return False
End Try
Return True
End Function
End Class