Question

I want to get the file name from user and then according to that name i will get another input. It's a multi input multi output problem. So i Normalized the problem as below.

1.I am using Script Tast in Control flow And asked to enter the file Name Using a form in C#. I am getting file name as browsing the file.

2.Then Unzip the file and check the name of the file according to the name of the file i set 3 varible which are globel.

3.According to variables i took 3 Data flow tasks. And its working well for the above specified problem.

4.Its Working for different Data flow tasks.

But i have another issue in this when i am using the flat file source name as dynamicly(Using Expression) It is giving me error about the Can not open the file.

Error "[Flat File Source [1]] Error: Cannot open the datafile "C:\Documents and Settings\XQN4P\Desktop\Inputs\Intraday\OPTION_DAILY_INTRADAY_ASIA20140212.csv". "

Note this file is generated from Unziping the entered file by user.

There is warning as well "[Flat File Source [1]] Warning: The process cannot access the file because it is being used by another process. ".

here is the code i am using to unzip it.

}
private void unzipInFile(string inputFilePath, string destDirectory,string destFileName)
{
    FileStream fsIn  =new FileStream (inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
    FileStream fsOut =new FileStream(destDirectory +"\\"+destFileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
     int  buffersize = 4096;
    int count = 0;
    var   buffer= new byte [buffersize]; 
    //using (Stream compressed = File.OpenRead(inputFilePath))
    //using (ZlibStream zlib = new ZlibStream(compressed, CompressionMode.Decompress))
    using(GZipStream gZip  = new GZipStream(fsIn, Ionic.Zlib.CompressionMode.Decompress, Ionic.Zlib.CompressionLevel.BestCompression, true ))

    {
        byte[] buf = new byte[short.MaxValue];
        int bufl;
        while (0 != (bufl = gZip.Read(buf, 0, buf.Length)))
        {
            if (count != 0) 
                fsOut.Write(buffer, 0, count);
            if (count != buffersize)
                 return ;
        }
    }
    fsOut.Close();


}

Another Address variable

Dts.Variables["FileAddress"].Value = filePath + ".csv";

SSIS structure.: "ScriptTask" sending output to 3 Data Flow Tasks.

Was it helpful?

Solution

Problem Solved. Problem was in formating of the unzipped file. It was not able to get the row delimiter. And some times file was still in use. So i worked around for this and it's ok

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top