Search code examples
ssisssis-2012

Create a txt file with SSIS showing File Movements


I need to create a .txt file every time and SSIS job runs and in that file I need to put the name of the files that I am transmitting. I have a foreach container but I am not sure on how to create the file and then write to it as each file is being moved. Can someone please steer me in the right direction? Thanks in Advance.


Solution

  • You can follow below steps:

    1. Create a dummy empty text file
    2. Copy the dummy file to new name dummyfile_10252016 (using File System Task - need to handle it through variable to make the name dynamic)
    3. Create variable to keep the dummyFilePath
    4. Process your required files in for each loop and store the filename in a variable
    5. Once your file is processed, write the name to dummyfile_10252016

    Script task:

    string filename = Dts.Variables["User::filename"].Value.ToString();
    string path = Dts.Variables["User::dummyFilePath"].Value.ToString();;
    
    System.IO.File.AppendAllText(path, filename );
    

    enter image description here