Friday, January 28, 2011

Copy File to all the subfolders

An example to copy a file from one location to all the subfolders for a target location.

Step 1 : Script , to get the list of all the subfolders and assigning to a object.


Dts.TaskResult = ScriptResults.Success

Dim fileLoc, fileName As String
fileLoc = ReadVariable("FileFolderLoc")
fileName = ReadVariable("FileName")

Dim diSource As DirectoryInfo = New DirectoryInfo(fileLoc)

Dim arr As New System.Collections.ArrayList()
For Each subdir In diSource.GetDirectories()

arr.Add(subdir.Name)

Next

WriteVariable("SubDirectoryObject", arr)


Step 2 : For each Loop container  as below



Step 3 : File copy to task to copy the files to the subfolder


.

No comments:

Post a Comment