1

I'm new to SSIS and am learning by the power of Google. I have a package but before it runs, I need to check if any csv exist in a folder. If they do, then continue, otherwise stop.

I've been watching you tube videos like the below: https://www.youtube.com/watch?v=qgqyQm6EymU

but this only chekcs for a specific file - I need to check if any csv's exist in a folder regardless of there name - how do I do this?

Thanks.

Hadi
  • 36,233
  • 13
  • 65
  • 124
Michael
  • 2,507
  • 8
  • 35
  • 71

2 Answers2

1

You can do this in a custom script.

See SSIS Script task to check if file exists in folder or not for the details about hooking up the script task. You don't need the file and fullPath variables, just the folder variable.

Substitute Directory.EnumerateFiles(folder, "*.csv").Any() for File.Exists in the above link.

Dts.Variables["User::fileExists"].Value = Directory.EnumerateFiles(folder, "*.csv").Any();
John Mo
  • 1,326
  • 10
  • 14
  • Hi there, I have the same problem as original poster, but I cant use your solution because I can not use .Any(), any ideas why? – SQL_Noob Dec 15 '22 at 20:16
  • 1
    @SQL_Noob .Any() is a Linq method. You might need to add the `using Sytesm.Linq` statement? – John Mo Dec 16 '22 at 21:18
0

If you don't want to mess with the SSIS script component, you can use the
File Properties Task on Codeplex.

Derrick Bell
  • 2,615
  • 3
  • 26
  • 30