Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/zip folder
Required plugins for this example: MBS Compression Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/zip folder
This example is the version from Sun, 31th Oct 2015.
Project "zip folder.rbp"
Filetype text
End FileTypes
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
EventHandler Sub Open() dim f as FolderItem = Createfiles dim s as FolderItem = SpecialFolder.Desktop.Child("test.zip") dim z as new ZipMBS(s,0) ZipFolder z,f,"" z.Close("global comment") End EventHandler
Function CreateFiles() As FolderItem dim folder as FolderItem folder=SpecialFolder.Desktop.Child("ziptest") folder.CreateAsFolder dim subfolder as FolderItem = folder.Child("test folder") subfolder.CreateAsFolder dim subsubfolder as FolderItem = subfolder.Child("test subfolder") subsubfolder.CreateAsFolder dim p as Picture= LogoMBS(500) dim file as FolderItem file = folder.Child("logo in folder.jpg") file.SaveAsJPEG p file = subfolder.Child("logo in subfolder.jpg") file.SaveAsJPEG p file = subsubfolder.Child("logo in subsubfolder.jpg") file.SaveAsJPEG p Return folder End Function
Sub ZipFile(z as ZipMBS, f as FolderItem, path as string) dim d as date dim b as BinaryStream dim info as ZipFileInfoMBS b=f.OpenAsBinaryFile(false) if b = nil then Break // failed to open? Ignore? return end if info=new ZipFileInfoMBS info.SetDate f.ModificationDate info.ExternalFileAttributes=0 info.InternalFileAttributes=0 info.DosDate=0 z.CreateFile path+f.name, info, "", "", "", z.MethodDeflated, z.CompressionBestCompression while not b.EOF z.Write b.Read(100000) wend z.CloseFile End Sub
Sub ZipFolder(z as ZipMBS, source as FolderItem, path as string) dim f as FolderItem dim i,c as integer path=path+source.Name+"/" c=source.Count for i=1 to c f=source.TrueItem(i) if f=nil then 'ignore elseif f.Directory then ZipFolder z, f, path else ZipFile z, f, path end if next End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Compression Plugin.

MBS FileMaker Plugins