Results 1 to 2 of 2

Thread: Zip file to a zipped folder

  1. #1

    Thread Starter
    Addicted Member DanCool999's Avatar
    Join Date
    Jul 2006
    Posts
    141

    Zip file to a zipped folder

    I'm wondering how I can move a file to an already zipped file folder.

    Example:

    Move myfile.txt to zippedfile.zip\new folder\items\

    I tried using the command line in 7 zip but couldn't find the right paramentors. If this can be done through VB or command line, Ill take either way.

    Thanks.
    Dan " "

    Visual Basic Professional 6.0

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Zip file to a zipped folder

    I tried the code posted here, then modified the Sub Zip_Activity so it only creates a zip file if the zip file doesn't already exists, otherwise the code created the zip file and the original contents of the zip file were lost.

    Sub Zip_Activity.....
    Code:
        Select Case UCase$(Action)        
            Case "ZIPFILE"            
                If Right$(UCase$(sFileDest), 4) <> ".ZIP" Then
                    sFileDest = sFileDest & ".ZIP"
                End If
            
                ' Only create zip if zip not found!
                If bFileExists(sFileDest) = False Then
                    If Not Create_Empty_Zip(sFileDest) Then
                        GoTo EH
                    End If
                End If
    
                Set ShellClass = New Shell32.Shell
                Set Filedest = ShellClass.NameSpace(sFileDest)            
                Call Filedest.CopyHere(sFileSource, 20)

    ' Check for file exist sub...
    Code:
    Private Function bFileExists(sFile As String) As Boolean
        On Error Resume Next
        bFileExists = ((GetAttr(sFile) And vbDirectory) = 0)
    End Function
    Once the source file is added to your zip you can just use the Kill command to delete the source file.

    I tried using the move command Call Filedest.MoveHere(sFileSource, 20) but the source file didn't get deleted, but did get added to the zip file.

    hth,
    Ed
    Last edited by Edgemeal; Feb 13th, 2009 at 08:52 PM.

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