Example: /Compression/Old ZipMBS class/zip folder with encryption

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/Old ZipMBS class/zip folder with encryption


Required plugins for this example: MBS Main Plugin, MBS Compression Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/Old ZipMBS class/zip folder with encryption

This example is the version from Sun, 31th Oct 2015.

Project "zip folder with encryption.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
EventHandler Sub Open() const password = "Hello" dim f as FolderItem = Createfiles dim s as FolderItem = SpecialFolder.Desktop.Child("test.zip") dim z as new ZipMBS(s,0) ZipFolder password, 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(password as string, z as ZipMBS, f as FolderItem, path as string) const WindowBits = 15 const memLevel = 8 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 dim data as string = b.Read(b.Length) dim crc as integer = CRC32StringMBS(0, data) z.CreateFile path+f.name, info, "", "", "", z.MethodDeflated, z.CompressionBestCompression, false, false, WindowBits, memLevel, z.StrategyDefault, password, crc z.Write data z.CloseFile End Sub
Sub ZipFolder(password as string, 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 password, z, f, path else ZipFile password, 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:

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


💬 Ask a question or report a problem