Results 1 to 16 of 16

Thread: [RESOLVED] Using T-SQL to compress file using Windows compressing utility

Threaded View

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Using T-SQL to compress file using Windows compressing utility

    Can this be done? I've seen samples that uses winzip but I don't have winzip so I'm wondering if this is doable using the built-in windows compressing utility. This is the VB6 code that does it in Vista, not sure if this is convertible at all to T-SQL. The other option I am looking into is to make a small program/dll that will do it and be called from SQL Server.

    Code:
    Public Sub ZipFile(ByVal strFileToZip As String, ByVal strTargetZip As String, Optional ByVal bolFileType As Boolean = True)
        CreateEmptyZip strTargetZip
        Dim folder      As Folder3
        Dim zipObject   As IShellDispatch5
    
        Set zipObject = CreateObject("Shell.Application")
        Set folder = zipObject.nameSpace(strTargetZip)
    
        If bolFileType Then
            folder.CopyHere strFileToZip
        Else
            folder.CopyHere zipObject.nameSpace(strFileToZip).Items
        End If
    End Sub
    
    Private Sub CreateEmptyZip(ByVal sPath As String)
        Dim strZIPHeader As String
        
        strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String$(18, 0) ' header required to convince Windows shell that this is really a zip file
        CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write strZIPHeader
       
    End Sub
    Last edited by dee-u; Aug 26th, 2009 at 01:20 AM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width