PlanetSquires Forums

Support Forums => General Board => Topic started by: SeaVipe on February 24, 2021, 06:46:15 PM

Title: Zip Folder (Windows)
Post by: SeaVipe on February 24, 2021, 06:46:15 PM
General question: I need to work with files in a compressed (zip) folder (reading and writing). I've found a few somewhat convoluted examples in other languages (some time ago now) but porting them to FB looked to be a task most daunting - ergo I gave up :(
I'm going to give it another go so any ideas or even a starting point would be helpful :)
Title: Re: Zip Folder (Windows)
Post by: raymw on February 25, 2021, 09:14:04 AM
You can call 7-zip from a command line, so you could generate the commands you need in fb, and then 'run' the command. Not sure if that is what you want to do
Title: Re: Zip Folder (Windows)
Post by: SeaVipe on February 25, 2021, 12:46:58 PM
Thanks, Ray, I'll look into 7-Zip. I was hoping to find a FB/Win API solution.
Title: Re: Zip Folder (Windows)
Post by: Paul Squires on February 25, 2021, 02:23:34 PM
I had an application years ago that I needed zip support. I ended up going the same path as Ray and simply shelled the calls to 7-zip. It worked well and the application continues to function perfectly all these years later.
Title: Re: Zip Folder (Windows)
Post by: SeaVipe on February 25, 2021, 03:05:12 PM
I'm looking into it, thanks, Paul.
Title: Re: Zip Folder (Windows)
Post by: Paul Squires on February 25, 2021, 06:57:07 PM
Code: [Select]
   Shell "7z.exe a myzipfile.zip -pMyPassword -mx9 -aoa -r *.xls", 0   
      ' -r    recurse to subfolders
      ' -p    password protect
      ' -mx9  compression level 9
      ' -aoa  overwrite existing files without prompt

This was used with 7-zip version 9.20 from 2010 so who knows if it works now. It simply creates a password protected archive containing, in my case, *.xls spreadsheet files in the folder. Obviously I have changed the archive name and password in the above example. :-)


Title: Re: Zip Folder (Windows)
Post by: SeaVipe on March 01, 2021, 01:13:46 PM
Thanks, Ray & Paul. Using Paul's example with 7z 19.00 (x64) worked great - and screaming fast. I tested with a batch file using the -u switch on 487 files and all the console did was flash. However, the newly created zip folder contained the correct files. I'll add a PAUSE or TIMEOUT x to the batch file and use the Shell command for FB (in my batch files I use the >> to append XCOPY output to an existing log file).
Title: Re: Zip Folder (Windows)
Post by: Wilko Verweij on March 02, 2021, 06:48:01 PM
Not sure if this is what you are looking for, but there is also a set of (de)compress functions in the Win32 API. See https://docs.microsoft.com/en-us/windows/win32/cmpapi/-compression-portal (https://docs.microsoft.com/en-us/windows/win32/cmpapi/-compression-portal). Good luck, Wilko
Title: Re: Zip Folder (Windows)
Post by: SeaVipe on March 02, 2021, 08:01:09 PM
Thanks, Wilko, I'll definitely check it out.