Re: GETFILE() Inside .Zip files?
- From: Steve Meyerson <stevemeyerson@xxxxxxx>
- Date: Mon, 27 Aug 2007 19:14:16 GMT
Looks like a good approach, Roger, thanks. I tried the code on a small
zip file with 2 files inside. Both files were copied ok. Now all I
have to do is figure out how to copy selectively from a list of files
and folders inside the zip file.
Is there a "tutorial" or something on using Shell and its capabilities
in VFP? I couldn't find one on Google or in the VFP doc.
Steve
On Mon, 27 Aug 2007 05:55:05 +0930, "Roger Ansell"
<notmy@xxxxxxxxxxxxxxxxxxxx> wrote:
Hi,
There is a way which doesn't rely on third-party tools and
you can use VFP's standard GetFile dialog.
OK, your user gets the zip file name he wants to extract from
GetFile(). You then extract the path and file name to
separate variables, eg:
lcFile = GetFile()
lcPath = JustPath(lcFile)
lcZipFile = JustFname(lcFile)
* Let's specify the destination path
* so your user doesn't have to intervene:
lcDestPath = "C:\MyApp"
* Now comes the tricky part <s>
Local loShell As "Shell.Application"
loShell = CreateObject("Shell.Application")
* Get a folder object for the source path:
loFolder = loShell.NameSpace(lcPath)
* Get a collection of the files in the folder:
loItems = loFolder.Items
* Now let's find the zip file we want:
For Each loItem In loItems
If Upper(loItem.Name) == Upper(lcZipFile)
* We've found the target zip file
loZip = loItem
Exit
EndIf
Next
* Return a folder object for the zip file
loZipFldr = loZip.GetFolder
* Get a collection of all the files in the zip
loZipItems = loZipFldr.Items
* Specify the destination folder object
loDestFolder = loShell.NameSpace(lcDestPath)
* Copy from the zip to the destination
loDestFolder.CopyHere(loZipItems)
All done!
HTH
-Roger
BTW there's an additional optional parameter
to the CopyHere() method which allows you to
handle how the extraction occurs.
These values are additive:
4 Do not display a progress dialog box.
8 Give the file being operated on a new name in a move, copy,
or rename operation if a file with the target name already exists.
16 Respond with "Yes to All" for any dialog box that is displayed.
64 Preserve undo information, if possible.
128 Perform the operation on files only if a wildcard file name (*.*) is specified.
256 Display a progress dialog box but do not show the file names.
512 Do not confirm the creation of a new directory if the operation requires one to be created.
1024 Do not display a user interface if an error occurs.
2048 Version 4.71. Do not copy the security attributes of the file.
4096 Only operate in the local directory. Don't operate recursively into subdirectories.
9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.
"Steve Meyerson" <stevemeyerson@xxxxxxx> wrote in message
news:6j01d3lnm449p6cuisk70lan75qecm3kl8@xxxxxxxxxx
The GETFILE() dialog window in VFP8 & 9 closes when I select a file
with the .zip extension and the function returns the path and name of
the .zip file.
Is there a way in VFP to display and select a file inside the .zip
file, as in Windows Explorer?
TIA
Steve M.
.
- Follow-Ups:
- Re: GETFILE() Inside .Zip files?
- From: Roger Ansell
- Re: GETFILE() Inside .Zip files?
- References:
- GETFILE() Inside .Zip files?
- From: Steve Meyerson
- Re: GETFILE() Inside .Zip files?
- From: Roger Ansell
- GETFILE() Inside .Zip files?
- Prev by Date: How to create activex object
- Next by Date: Re: How to create activex object
- Previous by thread: Re: GETFILE() Inside .Zip files?
- Next by thread: Re: GETFILE() Inside .Zip files?
- Index(es):
Relevant Pages
|