Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract file on zip with folders
Message
From
10/09/2016 19:52:29
 
 
To
10/09/2016 18:42:48
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
Hyper-V
Miscellaneous
Thread ID:
01640677
Message ID:
01640686
Views:
168
>the file's folder position is not fixed.
>Need to cross the tree.
>I need something similar to ADIR ()

This will return .T. if a file or a folder exists somewhere in the zip file and could be extracted.
? ExtractFileOrFolderInZipFile(m.ZipFile, m.FileOrFolderToExtract, m.TargetFolder)

FUNCTION ExtractFileOrFolderInZipFile(ZipFile AS String, ToExtract AS String, Location AS String, ShellExplorer AS Object, Tree AS String)

	LOCAL ShellObject  && edited

	IF PCOUNT() < 4
		m.ShellExplorer = CREATEOBJECT("Shell.Application")
		m.Tree = ""
	ENDIF

	FOR EACH m.ShellObject IN m.ShellExplorer.NameSpace(m.ZipFile + IIF(EMPTY(m.Tree),"","\" + m.Tree)).items

		IF UPPER(m.ShellObject.Name) == UPPER(m.ToExtract)
			m.ShellExplorer.NameSpace(m.Location).CopyHere(m.ShellExplorer.NameSpace(m.ZipFile).items.Item(m.Tree + m.ToExtract))
			RETURN .T.
		ELSE
			IF m.ShellObject.IsFolder AND ExtractFileOrFolderInZipFile(m.ZipFile,m.ToExtract,m.Location,m.ShellExplorer,m.Tree + m.ShellObject.Name + "\")
				RETURN .T.
			ENDIF
		ENDIF
		
	ENDFOR

	RETURN .F.

ENDFUNC
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform