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

Check your regions people

Today I was having a nice discussion with some colleagues about Fabric and pricing/licensing came…

1 week ago

Book Review – Deciphering Data Architectures

I recently purchased and read the book Deciphering Data Architectures - Choosing Between a Modern…

3 weeks ago

Fabulous Stuff in Fabric – Part 5: Folders in Workspaces

A while ago I had a little blog post series about cool stuff in Snowflake. I’m…

4 weeks ago

Speaking at dataMinds Saturday & Techorama 2024

I have the pleasure to announce I'll be presenting at two conferences this spring. The…

1 month ago

Change Notebook Spark Session Time-Out in Microsoft Fabric

You might know the feeling: you're writing code in a Notebook in Microsoft Fabric and…

1 month ago

How to Retrieve all the Spark Session Configuration Variables in Microsoft Fabric

I was trying some stuff out in a notebook on top of a Microsoft Fabric…

1 month ago