Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Zip
Message
From
12/10/2007 14:31:41
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Re: Zip
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01257796
Message ID:
01260679
Views:
30
This message has been marked as the solution to the initial question of the thread.
I think you have encountered the bug that occurs when zipping to a file that is not in the relative path of the stuff being zipped (or something like that).

Here's what I did to get around that bug:

I created a program called GetAllFiles:
LPARAMETERS tcCursorName, tcFromFolder

LOCAL lnFileCount
LOCAL ARRAY laFiles[1]

ADIR(laFiles, ADDBS(m.tcFromFolder) + "*.*", "HDS")
FOR lnFileCount = 1 TO ALEN(laFiles,1)
	IF laFiles[lnFileCount, 1] # "." AND laFiles[lnFileCount, 1] # ".."
		IF "D" $ laFiles[lnFileCount,5]
			GetAllFiles("c_FilesToBackup", ADDBS(m.tcFromFolder) + laFiles[lnFileCount, 1])
		ELSE 
			INSERT INTO (m.tcCursorname) VALUES (ADDBS(m.tcFromFolder) + laFiles[lnFileCount,1])
		ENDIF 
	ENDIF 
ENDFOR 
I then can zip up a folder (and all sub-folders) like this:
 IF ZipOpen(m.lcToFile) 
  m.llSuccess = .T.
  * get all files into a cursor
  CREATE CURSOR c_FilesToBackup (mFileName M(4))
  GetAllFiles("c_FilesToBackup", m.tcFromFolder)
  SELECT c_FilesToBackup
  m.lnFilesToBackup = RECCOUNT("c_FilesToBackup")
  m.loThermo = createobject("frmThermoBar", ;
                          "Backing up files..." , ;
                          m.lnFilesToBackup)
  m.lnCount = 0
  SCAN 
   SCATTER MEMVAR memo  
   m.lnCount = m.lnCount + 1 
   m.lcDisplay = X7DISPTH(STRTRAN(m.mFileName, m.tcFromFolder, ""), m.loThermo.lblMessage)
   m.loThermo.UpdateStatusBar((m.lnCount*100)/m.lnFilesToBackup, m.lcDisplay)
   m.lcRelativePath = STRTRAN(STRTRAN(m.mFileName, m.tcFromFolder, ""), JUSTFNAME(m.mFileName), "")
   IF NOT ZipFileRelative(m.mFileName, m.lcRelativePath)
    m.llSuccess = .F.
    EXIT 
   ENDIF 
  ENDSCAN

  IF m.llSuccess AND ZipClose()
   m.llSuccess = .T.
  ENDIF
  RELEASE LIBRARY VFPCompression.FLL
 ENDIF
Hope this helps


>I tried again as the code below
>No errors message, but no action neither
>I all want to do is to zip the folder "dados1"
>
>
>
>SET LIBRARY TO LOCFILE("vfpcompression.fll")
>* ?ZipOpen("C:\MyZipFile.zip")
> ZipOpen("test1.zip", "C:\1softwares\1_assist41X\ofi3a\dados1", .F.)
> ZipFolder("C:\test2", .F.)
> ZipClose()
>SET LIBRARY TO
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform