User (Old forums)MemberFebruary 3, 2010 at 12:20 amPost count: 23064
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?
Imported from legacy forums. Posted by Dan (had 1101 views)User (Old forums)MemberFebruary 3, 2010 at 8:12 amPost count: 23064
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
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… 🙂
Imported from legacy forums. Posted by Dan (had 282 views)Xceed SupportMemberFebruary 3, 2010 at 11:37 amPost count: 5658
You could use the ByteProgression event to get the zip file size as shown in: http://doc.xceedsoft.com/products/Xceedfilesystem/ByteProgression_event.html.
Imported from legacy forums. Posted by Mohamed [Xceed] (had 1349 views)
- You must be logged in to reply to this topic.