*-- Create / Open Zip File --- llZipOpen=ZipOpen(lcFullPath) *-- Make a call to Zip up the target folder ------------- llZipEmUp=ZipFolder(lcFilePathToZipUp) && No password specified here!!!! *-- Close the zip and display message --------------- llZipClose=ZipClose()Here is the Help info on ZipFolder that mentions the password parameter:
Function ZipFolder() Signature: ZipFolder(cFolderName[,lIgnorePaths[, cPassword]]) Parameters: cFolderName - The full path to the folder you wish to compress. lIgnorePaths - If you wish to ignore the relative path of the folder into the zip file that is being created you would pass .T. for this parameter. The default value for this parameter is .F. which means that paths will be respected. cPassword - The password you wish to protect the zipped file with. Return Value: Logical - returns .T. if successful or .F. if the operation has failed. Remarks: ZipFolder() is used between calls to ZipOpen() and ZipClose(). The usual series of function calls would consist of creating/opening the zip file using ZipOpen, zipping files and/or folders using ZipFile/ZipFileRelative/ZipFolder, and then closing the zip file using ZipClose.Here is my full code:
Set Library To 'D:\WORK\UTIL\VFP COMPRESSION\VFPCOMPRESSION.FLL' lcYear=Alltrim(Str(Year(Datetime()))) lcMonth=Padl(Alltrim(str(Month(Datetime()))),2,'0') lcDay=Padl(Alltrim(Str(Day(Datetime()))),2,'0') lcHour=Padl(Alltrim(Str(Hour(Datetime()))),2,'0') lcMinute=Padl(Alltrim(Str(Minute(Datetime()))),2,'0') lcSec=Padl(Alltrim(Str(Sec(Datetime()))),2,'0') lcFilePathToZipUp='\\fs4\work\data\' lcZipFilePath=('D:\Backups') lcZipFileName=lcYear+'.'+lcMonth+'.'+lcDay+'_'+lcHour+'h'+lcMinute+'m'+lcSec+'s.zip' *-- Create / Open Zip File --- lcFullPath=Addbs(lcZipFilePath)+lcZipFileName llZipOpen=ZipOpen(lcFullPath) If !llZipOpen MessageBox('Could not open zip file ' + lcFullPath) Return EndIf *-- Make a call to Zip up the target folder ------------- Wait 'Zipping ' + lcFilePathToZipUp + ' to ' + lcFullPath window nowait llZipEmUp=ZipFolder(lcFilePathToZipUp) If !llZipEmUp MessageBox('Unkown Error. Could not zip up files at ' + lcFilePathToZipUp) Return EndIf *-- Close the zip and display message --------------- llZipClose=ZipClose() If !llZipClose lcFinishedMessage='Could not close zip file:' Else lcFinishedMessage='Finished Zipping ' + lcFilePathToZipUp +' to file: ' EndIf MessageBox(lcFinishedMessage + ' ' + lcFullPath)>Check Thread #1379824