The zip from Command line is not working fat last for me in monterey…
The MBS compression plugins is nice,but i am confuse it.
Can someone that use give me a example how to zip a folder and file?
I have 1 folder and 1 file and i want them to be zipped WITHOUT the root Folder.
Is possible?
Thank you.
Well, the “zip folder” example should do this.
The path name put in the archive should be relative to your base folder.
But you may prefer to look into the /Compression/Archive/archive example since it uses newer archive classes.
@Christian_Schmitz thank you for the reply.
I have test the Commpression/archive the problem is still i get the Root folder as zipped inside.
If in my path put the child"/Content" then i get only the folder without the files.
The hierarchy is like the screenshot.
I want only the content and the root files
I am sure i Miss something !!
Sounds like you start a level too high?
You can of course change the entry.PathName and not include the temp/ prefix.
I Think my paths is ok.
Var f as FolderItem = TMPfolder //<-- /ioannis/temp
Var f as FolderItem = TMPfolder.child("") //<-- /ioannis/temp/
Var s as FolderItem = SpecialFolder.Desktop.Child("test.zip")
Var z as new ZipMBS(s,0)
ZipFolder z,f,""
z.Close("global comment")
Both paths Include the root folder “/temp” for some reason.
About the entry i think is ok
dim PathName as string = entry.PathName
dim FileName as string = NthField(PathName, "/", CountFields(PathName,"/"))
if left(FileName,1) = "." then Continue // skip
This is code I use to save one file into a zip file
You can iterate through your files and use the same.
Technically, you dont need to save an empty folder in there, you may just want to create folders later when you unpack
dim aFolderItem as FolderItem
dim aZipFolderItem as folderitem
dim zm as ZipMBS
dim info as ZipFileInfoMBS
dim b as BinaryStream
try
aZipFolderItem=specialfolder.applicationdata.child( "archive.zip" )
dim mode as integer = ZipMBS.AppendStatusCreate
if aZipFolderItem.Exists then
mode = ZipMBS.AppendStatusAddInZip
end if
zm=new ZipMBS(aZipFolderItem,mode)
info=new ZipFileInfoMBS
info.SetDate new date
//get a file
b=f.OpenAsBinaryFile(false)
zm.CreateFile f.Name, info, "", "", "", zm.MethodDeflated, zm.CompressionBestCompression
while not b.EOF
zm.Write b.Read(100000)
wend
zm.CloseFile
zm.Close
catch
end try
Thank you @Jeff_Tullin but is not what i want.
The above can be done with terminal to append files or directories…
If the MBS do not have this simple procedure as function then i can use, to simple zip folder and files without the root included then i go for alternate method.