File system task is used to move the one file from the source to the archive folder at a one time.
Read
here: https://bageshkumarbagi-msbi.blogspot.com/2014/12/file-system-task.html
We have a requirement like after loading the n number of files we need to move these files
into the Archive folder.
With the help of script task, we can achieve the same.
Let’s see in
this demo
Source Folder
Archive Folder
Taking Script task
Taking
variables to store the source and archive folder path.
Now in
script task we are writing the below code.
public void Main() { string sourcePath = Dts.Variables["User::Source_dir"].Value.ToString(); string targetPath
=Dts.Variables["User::Archive_dir"].Value.ToString(); { Directory.CreateDirectory(targetPath); } { string fileName = Path.GetFileName(sourcefile); string destFile = Path.Combine(targetPath,
fileName); } } |
Compile this
code saves and close this window.
Now package
is ready to run.
Running this
package.
Package
executed successfully.
See the
Archive folder.
Files moved
to the Archive folder successfully.