SSIS Create New Folders On The Fly When Writing To A Flat File Connection I have an SSIS package that is meant to write to multiple files, which are stored like 

\\server\MainFolder\DynamicField1\DynamicField2\File.csv 


where the subfolders DynamicField1 and DynamicField2 are not necessarily in existence, but are coming from the variable i store for the ConnectionString.

When I run the package from my desktop, I get the message:

[File [2]] Warning: The system cannot find the path specified.


The error goes on to say:

[File [2]] Error: Cannot open the datafile "\\server\folder\abcd\efgh\filename_20190606115901.csv".


That looks like a good file name. 

I tried replacing the dynamic folders with a dash so that the file name would look like:

\\server\folder\abcd - efgh - filename_20190606115901.csv


and that actually seemed to work. The problem is, there will be hundreds of files and it would be best if they could be organized in two levels of sub folders.

Does this mean that I cannot create folders on the fly?
You need to use a File System Task and set the Operation to Create Directory. Pass it a variable of the file path without the filename and it should create the directory.

See this blog article for a good example of creating folders from dynamic paths.