Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Script task not unzipping

$
0
0

Hi,

I am using follwing script to unzip files in package. But unfortunately the code is not working. I had added reference dll as well. The script task doesnt unzip the file to location (vUnzipLocation).

Imports java.util.zip

Try
            Dim strSourceFile As String
            Dim strDestinationDirectory As String

            'MsgBox("Current File: " & Dts.Variables("FileName").Value.ToString)

            strDestinationDirectory = Dts.Variables("User::vUnzipLocation").Value.ToString
            strSourceFile = Dts.Variables("User::vFolder").Value.ToString & Dts.Variables("User::vFileName").Value.ToString

            Dim oFileInputStream As New java.io.FileInputStream(strSourceFile)
            Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
            Dim bTrue As Boolean = True
            Dim sbBuf(1024) As SByte

            While 1 = 1

                Dim oZipEntry As ZipEntry = oZipInputStream.getNextEntry()

                If oZipEntry Is Nothing Then Exit While

                If oZipEntry.isDirectory Then

                    If Not My.Computer.FileSystem.DirectoryExists(strDestinationDirectory & oZipEntry.getName) Then

                        My.Computer.FileSystem.CreateDirectory(strDestinationDirectory & oZipEntry.getName)

                    End If

                Else

                    Dim oFileOutputStream As New java.io.FileOutputStream(strDestinationDirectory.Replace("\", "/") & oZipEntry.getName())

                    While 1 = 1

                        Dim iLen As Integer = oZipInputStream.read(sbBuf)

                        If iLen < 0 Then Exit While

                        oFileOutputStream.write(sbBuf, 0, iLen)

                    End While

                    oFileOutputStream.close()

                End If

            End While

            oZipInputStream.close()
            oFileInputStream.close()


        Catch ex As Exception

        End Try

Any suggestions?

Thanks,


hsbal


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>