343
343

Reputation: 305

Empty Text File in SSIS Package

In my Project, I want to create one empty text file when the package triggered.

Upvotes: 3

Views: 7398

Answers (2)

Kash
Kash

Reputation: 1

It might be good idea to dispose of the FileStream object after using the File.Create method to avoid locking issues.

Read more here System.IO.File.Create locking a file

Upvotes: 0

billinkc
billinkc

Reputation: 61211

I'd probably just use a one-line Script task.

System.IO.File.Create(@"C:\OneEmptyTextFile.txt");
  1. On your Control Flow, drag a Task of type Script Task from your SSIS Tool Box
  2. Double click on the new Script Task
  3. In the Script Task Editor, click Edit Script...
  4. In the public void Main() section, where it states // TODO: Add your code here replace that line with the above code. If you are using SSIS 2005 or if you have chosen to use VB.NET in 2008/2012, please remove the trailing semicolon.
  5. Click the X button in the upper right corner of the Integration Services Script Task window
  6. Back in the Script Task Editor, click OK.

Now whenever that Task runs, it will use the static Create method of the File object to create a file in the requested location.

Upvotes: 9

Related Questions