SSIS Script Task Copy Files From One Folder into Multiple Folders

Ronald Van Der Westhuizen 41 Reputation points
2022-03-31T18:35:35.543+00:00

Greetings Developers

I Hope Everyone is doing okay

i have a problem

allow me to walk you through it

i have a SQL table that has a result set of two columns named, 'SourceFilefolders' and destination'filefolders'

within those two those results sets has different folder locations and different files

basically what i am trying to do is following

  1. take the files within the source folder locations and place them into the same named folder locations placed on another server

i have tried every possible logic out there and it seems to be not working

![188838-image.png]2

i have attached even the ssis package to show what i am talking about

188932-image.png

The Script take to make folder 1 is as follows

Public Sub Main()  
    Dim directory As Directory  
    Dim file As File  
    Dim filepath As String  
    filepath = Dts.Variables("ServerLocation").Value.ToString() + Dts.Variables("Folder1").Value.ToString()  
    'file.Create(filepath)  
    Directory.CreateDirectory(filepath)  
    Dts.TaskResult = ScriptResults.Success  
End Sub  

However to move the file from 'destination'filefolders' to 'SourceFilefolders' is what i am struggling with

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,362 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,525 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,601 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 35,556 Reputation points
    2022-04-01T06:25:21.027+00:00

    Hi @Ronald Van Der Westhuizen ,

    I'm not familiar with code writing, from SSIS side, to move files between servers, you may use File System Task.

    If it's a remote server you need a shared folder and correct permission to do it.

    file-system-task

    If you want to do this with C#, check below link to see if it is helpful.

    how-to-copy-file-from-one-server-to-other-which-is-in-different-enviroment

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Olaf Helper 43,246 Reputation points
    2022-04-01T06:37:37.587+00:00

    Why with a .NET script task and not simply using a File System Task?

    0 comments No comments