Categories: SSIS

Reblog: Unexpected result with the File System Task

SQLKover update: nowadays you would probably use package parameters to pass the directory value. However, they still have a default value, so this still applies.

Recently I ran across a forum thread where someone encountered an unexpected result when creating a directory using the File System Task in Integration Services. He used a variable to specify the name of the directory to be created and this variable was populated by a parent package configuration. If the configuration failed, he didn’t want the package to create the directory specified during design time, so he entered “invalid” in the variable value, expecting the package to fail as it is not a correct path to a directory. This is a common (best) practice to make sure the package doesn’t change your development environment if the configuration in production fails. If you get for example an error from a flat file source saying: “cannot find file invalid”, you immediately know the problem lies with the package configurations.

However, the package did not fail. Instead, it created a directory called Invalid. I recreated the set-up using this simple package:

When I run the package using SSIS 2012 in Windows 8, the folder HelloWorld!!! Is created in the same folder where the SSIS package is stored. On another computer – using SSIS 2008R2 in Windows XP – the folder is created in the My Documents folder. The guy from the forum thread mentioned his folder was created on his desktop. The documentation doesn’t mention where a directory is created when there is no absolute path specified and a quick Internet search didn’t yield an explanation either. It’s also unclear if the choice where the directory is finally created is influenced by the version of SSIS, the OS version (an environment variable?) or some obscure setting no one knows about.

Conclusion: very unpredictable results. The directory might still be created and who knows where all your files end up. Better avoid this way of working with a file system task. If you really want to validate directory paths and handle exceptions, I recommend a script task.


------------------------------------------------
Do you like this blog post? You can thank me by buying me a beer 🙂
Koen Verbeeck

Koen Verbeeck is a Microsoft Business Intelligence consultant at AE, helping clients to get insight in their data. Koen has a comprehensive knowledge of the SQL Server BI stack, with a particular love for Integration Services. He's also a speaker at various conferences.

View Comments

  • There are differences between XP and win7 onwards for the users default directory.
    For example on win xp the user directory is located at

    C:\documents and settings\username\

    On win7 upwards it will be

    C:\users\username\

    The users default directory is likely different too but I haven't checked to confirm. The task seems to check if the folder exists if not it just creates it. I believe setting UseIfDirectoryExists to false will produce a failure otherwise as we see the object is simply created if it doesn't exist
    Regards perry

Recent Posts

Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions

I'm hosting a free webinar at MSSQLTips.com at the 19th of December 2024, 6PM UTC.…

5 days ago

dataMinds Connect 2024 – Session Materials

The slides and scripts for my session "Tackling the Gaps & Islands Problem with T-SQL…

4 weeks ago

Connect to Power BI as a Guest User in another Tenant

Sometimes your Microsoft Entra ID account (formerly known as Azure Active Directory) is added as…

2 months ago

How to use a Script Activity in ADF as a Lookup

In Azure Data Factory (ADF, but also Synapse Pipelines and Fabric Pipelines), you have a…

4 months ago

Database Build Error – Incorrect syntax near DISTINCT

I wrote a piece of SQL that had some new T-SQL syntax in it: IS…

4 months ago

Speaking at dataMinds Connect 2024

I'm very excited to announce I've been selected as a speaker for dataMinds Connect 2024,…

5 months ago