>I have qa need to implement a zip function in my application
>This is the code I am using (not mine... don't remember where I got it from <bg>)
>
>LOCAL lcZipFileName,lcDataPath
>IF TYPE('oApp')='O'
> lcDataPath=oApp.DataLocn
>ELSE
> lcDataPath='DATA'
>ENDIF
>lcZipFileName=ADDBS(lcDataPath)+'AFIles'+SYS(2015)+"_"+TTOC(DATETIME(),1)+".ZIP"
>strtofile(chr(0x50)+chr(0x4B)+chr(0x05)+chr(0x06)+replicate(chr(0),18),lcZipFileName)
>oShell=CREATEOBJECT("shell.application")
>FOR EACH ofile IN oShell.NameSpace(lcDataPath).items
> oShell.NameSpace(cFileZip).copyhere(ofile)
>ENDFOR
>
>Code fails on NameSpace line
>Error is: Member Namespace does not evaluate to an object.
>
>Also, I only want to archive files that start 'A_'
>
>How do I modify the code above to only include files of the above type?
>
What is your operating system?
I use
loZip = CreateObject("XStandard.Zip")
FOR lnI = 1 TO ALEN(laFiles)
loZip.Pack(laFiles[m.lnI], m.lcBackUpDir + m.lcZipFile, .t.)
next
You can create a list of files starting with A_ using
ADIR(laFiles,myPath + "A_*.*")
xzip.dll was recommended by Frank Cazabon. See
Re: Today's work - all gone :( Thread #
1199789 Message #
1200096 I like it so far, though there are lots of other alternatives to do zipping in VFP.
In this thread you can see discussion for all alternatives
Zipping in VFP Thread #
1125311
If it's not broken, fix it until it is.
My Blog