Welcome to the Xceed Community | Help
Community Search  
More Search Options

Getting ongoing zip file size

Sort Posts: Previous Next
  •  02-03-2010, 12:20 AM Post no. 25638

    Getting ongoing zip file size

    As I add files to a zip archive, can I discover the current size of the zip file that is being created?

    I want to manage my own file splitting so need to do a check of the current zipfile size.     Any suggestion on how that can be done?   I haven't found anything obvious...

     I create a zipfile

    m_zipRoot  = New Xceed.Zip.ZipArchive(sZipper)

    As I copyto this zipfile, can I test for it's current size after adding each file?

     

    Des


    Dan Desjardins
    Product Manager
    Weather Central, LLC
    Madison, WI
  •  02-03-2010, 8:12 AM Post no. 25642 in reply to 25638

    Re: Getting ongoing zip file size

    I think I have my method for this....

    Here's what I do:  (highly condensed code snipit)

    Dim lTotalZipSize as Long = 0L

     m_zipRoot  = New Xceed.Zip.ZipArchive(MyZipFile)

    For each Filename in Filenames

                        File = New DiskFile(Filename)
                        DestFile = m_zipRoot.GetFile(File.FullName)
                        File.CopyTo(m_zipEvents, Nothing, DestFile, True)
                        lTotalZipSize += DestFile.CompressedSize
                       

                       if lTotalZipSize >= MyThreshold then

                       'do what I need to do at this point

                       End if

    Next Filename

     

    lTotalZipSize increments by the amount of the last compressed file size and I can test it whenever I need to.   The only problem with this approach is that I can't really know I've exceeded MyThreshold until I actually do.  With a large file I could exceed it by A LOT!    So if I want a zip file to be no larger than 10 megabytes then it's very likely the last file I add could take it WAY over 10 megabytes.   Since I have to add it to the archive to get the compressed size I really have no choice.    If I absolutely *HAVE* to make sure I don't exceed a certain size then I would need to create a test archive for each one to see how much it compresses.   I suppose I could do that, but that would slow down the process so significantly that it just wouldn't be worth it.  I suppose I could also look at the filesize and type I'm about to compress and determine a rough ratio before I add it.   That would likely bring it pretty close to my goal.   This approach seems decent enough - at least for now.

    If anyone sees a flaw in my logic please feel free to insult me... :-)

    Des


    Dan Desjardins
    Product Manager
    Weather Central, LLC
    Madison, WI
  •  02-03-2010, 11:37 AM Post no. 25648 in reply to 25638

    Re: Getting ongoing zip file size

    Hi Dan,

    You could use the ByteProgression event to get the zip file size as shown in: http://doc.xceedsoft.com/products/Xceedfilesystem/ByteProgression_event.html.


    Xceed - Software Developer and Technical Support
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.