FoxPro Programming
How To Zip Files
Gravatar is a globally recognized avatar based on your email address. How To Zip Files
  Steve
  All
  Aug 28, 2014 @ 06:32pm
Hi All,
For a long time, I have used the Windows Shell for Unzipping files. Now, I want to use the Windows Shell to Zip files, and cannot seem to find a working example.
Can someone help me out?

TIA,
Steve

Gravatar is a globally recognized avatar based on your email address. Re: How To Zip Files
  Steve
  Steve
  Aug 29, 2014 @ 06:22pm
Got it, I just wasn't using the examples on the web correctly. Sorry to bother.
Steve


Hi All,
For a long time, I have used the Windows Shell for Unzipping files. Now, I want to use the Windows Shell to Zip files, and cannot seem to find a working example.
Can someone help me out?

TIA,
Steve

Gravatar is a globally recognized avatar based on your email address. Re: How To Zip Files
  Rick Strahl
  Steve
  Aug 30, 2014 @ 02:25pm
Would you mind sharing what you found? Or links?

Rick


Got it, I just wasn't using the examples on the web correctly. Sorry to bother.
Steve


Hi All,
For a long time, I have used the Windows Shell for Unzipping files. Now, I want to use the Windows Shell to Zip files, and cannot seem to find a working example.
Can someone help me out?

TIA,
Steve



Rick Strahl
West Wind Technologies

Making waves on the Web
from Hood River

Gravatar is a globally recognized avatar based on your email address. Re: How To Zip Files
  Steve
  Rick Strahl
  Sep 1, 2014 @ 06:55am
Hi All,
Sure, here is what I ended up with, building on what I found on the net. It basically creates a zipped file from a single file within a folder.


*************************************************************************************************
* Zip_File
* Creates a Compressed Zip file
*************************************************************************************************

LPARAMETERS tcSource, tcTarget
IF PARAMETERS() <> 2
=MESSAGEBOX("Zip_File: Incorrect Parameters.",0+16,"Error",10000)
RETURN .F.
ENDIF

LOCAL lcPath, lcFile, lcTarget, llResult
lcPath = JUSTPATH(tcSource)
lcFile = JUSTFNAME(tcSource)
lcTarget = tcTarget
llResult = .T.

IF !FILE(tcSource)
=MESSAGEBOX("Zip_File: Source File not found.",0+16,"Error",10000)
RETURN .F.
ENDIF

* Must Create Zip File
STRTOFILE(CHR(0x50)+CHR(0x4B)+CHR(0x05)+CHR(0x06)+REPLICATE(CHR(0),18),lcTarget,0)
IF !FILE(lcTarget)
=MESSAGEBOX("Zip_File: Could not create Zip File.",0+16,"Error",10000)
RETURN .F.
ENDIF

WAIT WINDOW lcFile + " - Compressing file, please wait..." NOWAIT NOCLEAR

oShell = CREATEOBJECT("shell.application")
IF TYPE('oShell') = 'O' AND !ISNULL(oShell)

FOR EACH oFile IN oShell.NameSpace(lcPath).Items
IF oFile.Name = lcFile
oShell.NameSpace(lcTarget).CopyHere(oFile)
ENDIF
ENDFOR

ELSE
llResult = .F.
=MESSAGEBOX("Zip_File: Could not load Compression Utility.",0+16,"Error",10000)

ENDIF

oShell = NULL
WAIT CLEAR
RETURN llResult


HTH,
Steve



Would you mind sharing what you found? Or links?

Rick


Got it, I just wasn't using the examples on the web correctly. Sorry to bother.
Steve


Hi All,
For a long time, I have used the Windows Shell for Unzipping files. Now, I want to use the Windows Shell to Zip files, and cannot seem to find a working example.
Can someone help me out?

TIA,
Steve



© 1996-2024