Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/zip folder
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Compression/zip folder
This example is the version from Thu, 23th Dec 2009.
Notes: Last modified: Thu, 23th Dec 2009
Class Window1
Inherits Window
// Event implementations
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 Sub

// Methods
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
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)

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
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
End Class

Class App
Inherits Application
End Class


See also:




Links
MBS Realbasic PDF Plugins - Besuchen Sie die JUZ Nickenich Webseite