Need help with MBS Compression class

I’m having a problem creating a zip file and I’m hoping that someone can look at my code and tell me what I’m doing wrong. A little background: I’m developing and running my program on a 64bit Windows 7 machine. My code creates the Zip file and when I try to extract the compressed files on Windows I’m getting the error “The Compressed (zipped) Folder is invalid”. I copy the zipped file to my Yosemite machine and OS X extracts the zipped file without a problem. I haven’t been able to figure out the right code yet. Hopefully it’s something simple. BTW - BackupFile is a folderitem that is passed into this routine. I have verified that it is the file that I want to zip.

[code] Dim CompressedName As Text
Dim CompressFile As FolderItem
Dim ZipFile As ZipMBS
Dim BStream As BinaryStream
Dim WorkDate As Date
Dim Info As ZipFileInfoMBS
Dim ZipName As Text

ZipName = BackupFile.NativePath.ToText
ZipName = ZipName.Mid(2)
CompressedName = BackupFile.NativePath.ToText.Replace(".bak", “.zip”)
CompressFile = GetFolderItem(CompressedName, FolderItem.PathTypeNative)

ZipFile = New ZipMBS(CompressFile, 0)
BStream = BinaryStream.Open(BackupFile, False)

WorkDate = CompressFile.ModificationDate
Info = New ZipFileInfoMBS
Info.ExternalFileAttributes = 0
Info.InternalFileAttributes = 0
Info.DosDate = 0

ZipFile.CreateFile(ZipName, Info, “extra local1”, “extra global1”, “comment1”, ZipFile.MethodDeflated, ZipFile.CompressionBestCompression)
While Not BStream.EOF

ZipFile.Close(“global comment”)[/code]


I would just pass empty text for extra local and extra global fields. Also comment doesn’T sound good, so leave it away here?

I have tried it already with entry strings where the “extra local1”, “extra global1”, “comment1” and “global comment” parms are. I still gives me the same error when trying to unzip on Windows. I forgot to mention that I’m also using the 15.1 version of the plugins.

Do the example projects work?

Ok, I finally figured out a combination that works. Here is what I changed:

ZipFile.CreateFile(ZipName, Info, "extra local1", "extra global1", "comment1", ZipFile.MethodDeflated, ZipFile.CompressionBestCompression)


ZipFile.CreateFile(BackupFile.Name, Info, "", "", "Compressed Database Backup", ZipFile.MethodDeflated, ZipFile.CompressionBestCompression)

The change here is that I went from the full path to the file (minus the Drive letter) to just the file name.


While Not BStream.EOF ZipFile.Write(BStream.Read(100000)) Wend


[code] Dim Data As String
Data = BStream.Read(BStream.Length)

ZipFile.CreateFile(BackupFile.Name, Info, “”, “”, “Compressed Database Backup”, ZipFile.MethodDeflated, ZipFile.CompressionBestCompression)

The change here is that I’m reading the entire file from the binary stream into memory at one time. My MAJOR concern with this is that I know I’m going to have files that are anywhere from 100’s of MB to GB’s in size.

My code is pretty close to the example project so I’m inclined to say that the examples don’t work.

it should work in chunks.
But maybe the issue was simply using full path for the file in the archive. It should be a relative path.

I will leave the path the way I have it now and try it again in chunks. I will post back here with the results of that testing.