Solution: Please add Script Task and write following code inside it.
sourceFile.Close();
Public void Main(string[]
args)
{
string
srcPath = Dts.Variables["zipFiles"].Value.ToString();
//string
srcPath = @"C:\SQL3_Tasks\ssPharmacy\";
srcPath = srcPath + "\\";
string
FileName = getFileName(srcPath);//"SSPharmacy20150605.txt";
string
JustFileName = FileName.Substring(0, FileName.Length - 4);
FileInfo
fileToCompress = new FileInfo(srcPath
+ FileName);
FileStream
sourceFile = File.OpenRead(srcPath +
FileName);
FileStream
destinationFile = File.Create(srcPath +
FileName + ".gz");
byte[]
buffer = new byte[sourceFile.Length];
sourceFile.Read(buffer, 0,
buffer.Length);
using
(GZipStream output = new GZipStream(destinationFile,
CompressionMode.Compress))
{
output.Write(buffer, 0,
buffer.Length);
}
destinationFile.Close();
}
Detailed Description:
- DTS Variables: We can add variables into SSIS Package with different scope levels. We can pass any variable to script task. Following are the steps for passing any variable to Task:
- Edit Script Task, which will open Script Task Editor. Please see below screen shot:
- There are two sections where we can provide our variables:
- ReadOnlyVariables: in this section we can add only those variables which we want to provide as input only and which is needed for our functionality implementation in Script Task.
- ReadWriteVaraibles: In this section we can add those varibales which we want to fill as our functionality output.