One other method if you want to load the entire file path of the flat files is
- Right click on Flat File Source in Data Flow tab
- Click "Show Advanced Editor"
- Click "Component Properties"
- Under Custom Properties you will find "FileNameColumnName".
- If you give a name (e.g.: FlatFileName) then that will appear as one of the source output columns in mapping that contains the file name value(full path with file name). It can be mapped to any available column in destination or modified using Derived column task to get only file name.
In my development, I have stored mostly the entire path which helped me in better tracking.
One other method for anyone who comes across this question, instead of using ForEach loop you can also use a simpler method
- Right click in Connection Manager
- Click on "New Connection"
- Select "MULTIFLATFILE" connection type and click Add.
- In Connection manager editor, insert location and use wildcard * (E.g.: \\ABC\XYZ\file_*.txt) to pick all the flat files in that folder.
- This automatically loops through all the flat files in that folder.
Hope this helps!