Zip and Unzip files using Activex

  • Hi,

          I need an ACTIVE X script to Zip and Unzip the files. I will be getting files in a Zipped folder, i need to Unzip those. Can anyone please let me know as to how to do that. Thanks for your help.

     

  • Firstly you need a zip product that allows you to automate it via script, either through automation (COM) or through the command line (shell). Winzip has a command line executable that you could call via a windows scripting host shell. I'm sure there are other compression utilities that also allow you to shell out but I can't think of any at the moment.

    Your other alternative, depending on your programming environment/experience is to use a library such as ICSharpCode.SharpZipLib and wrap it in a custom .net (possibly COM interoperable) wrapper and call that instead.

  • I'd just use something like GZip and call it via WScript.Shell in the ActiveXScript task.

    Much, much easier.

     

    --------------------
    Colt 45 - the original point and click interface

  • I made a simple procedure some time ago which does what you are looking for.

     

    ALTER    PROCEDURE sp_Unzip (@SourceDir VARCHAR(100), @DestinationDir VARCHAR(100), @ZipFile VARCHAR(100))

    AS

    -- DECLARE @SourceDir VARCHAR(100), @DestinationDir VARCHAR(100), @ZipFile VARCHAR(100)

    -- SET @SourceDir = 'd:\'

    -- SET @DestinationDir = ''

    -- SET @ZipFile = 'unzip.zip'

    IF @DestinationDir = ''

    SET @DestinationDir = @SourceDir

    DECLARE @StrSQLUnzip NVARCHAR(1000)

    --DECLARE @StrSQLRemoveZip NVARCHAR(1000)

    SET @StrSQLUnzip = 'EXEC master..xp_cmdshell ' + '''' + 'wzunzip -o ' + @SourceDir + @ZipFile + ' ' +@DestinationDir +''''

    --SET @StrSQLRemoveZip = 'EXEC master..xp_cmdshell ' + '''' + 'DEL '+ @SourceDir + @ZipFile +''''

     

    EXEC (@StrSQLUnzip)

    --EXEC (@StrSQLRemoveZip)

  • I would just point out that ICSharpCode.SharpZipLib, as of writing time, has a nasty drawback; ICSharpCode.SharpZipLib  does not support any files greater then 4GB.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply