Tuesday 7 June 2016

Copying Multiple Files from difference sources and paste on a location


Guys I have a scenario in that I have an Excel file and the Excel file has the list of difference source files. Our job to read the source file path and copy the files from this source and paste it on the desirer location.
Below are the excel file

We need to copy these file and paste it on the below location
  

Let’s see how can we do

Package design
  
I am reading the FilefullPath and storing this value on the RecordSet destination after that taking Foreach loop container and selecting the ADO enumerator fetching the one by one record. Since value is an object type so we need to convert this value to string, I am using script task for this.

Double click on the Data flow task
Taking the excel source and configuring the required configuration
  
Now taking the RecordSet destination
  
Declaring the object type of variable to store the value
  
Configuring the required configuration
  
Map the Input Columns

No I am taking the Foreach loop container

Mapping the Variable

Click OK.
For Converting the Object type variable to String type I am taking the Script task.
Creating the variable to store the file path

Edit the script
    public void Main()
              {
                     // TODO: Add your code here
            //User::FilefullPath,User::objFilePaths
            object myObjectVar = Dts.Variables["User::objFilePaths"].Value;
            string myString = (string)myObjectVar;
            Dts.Variables["User::FilefullPath"].Value = myString.ToString();
            Dts.TaskResult = (int)ScriptResults.Success;
              }



Now I am taking the File System task.

Configuring the Source and Destination Connection
Now Package is ready to run.
See the destination folder before running the package

Now running the package

Package executed successfully.
See the destination folder




No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts