PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Zip Folder (Windows)  (Read 343 times)

SeaVipe

  • Senior Member
  • ***
  • Posts: 397
  • Windows 10
Zip Folder (Windows)
« 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 :)
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

raymw

  • Senior Member
  • ***
  • Posts: 415
Re: Zip Folder (Windows)
« Reply #1 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
Logged

SeaVipe

  • Senior Member
  • ***
  • Posts: 397
  • Windows 10
Re: Zip Folder (Windows)
« Reply #2 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.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9386
  • Windows 10
    • PlanetSquires Software
Re: Zip Folder (Windows)
« Reply #3 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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 397
  • Windows 10
Re: Zip Folder (Windows)
« Reply #4 on: February 25, 2021, 03:05:12 PM »

I'm looking into it, thanks, Paul.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9386
  • Windows 10
    • PlanetSquires Software
Re: Zip Folder (Windows)
« Reply #5 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. :-)


Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 397
  • Windows 10
Re: Zip Folder (Windows)
« Reply #6 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).
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Wilko Verweij

  • Junior Member
  • **
  • Posts: 167
  • PB10 - FF3.7 User; Win 10
    • CHEAQS
Re: Zip Folder (Windows)
« Reply #7 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. Good luck, Wilko
Logged

SeaVipe

  • Senior Member
  • ***
  • Posts: 397
  • Windows 10
Re: Zip Folder (Windows)
« Reply #8 on: March 02, 2021, 08:01:09 PM »

Thanks, Wilko, I'll definitely check it out.
Logged
Clive Richey
You're Either Part Of The Solution, Or You're The Problem.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!