Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Zipping files from inside VFP
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01222560
Message ID:
01222648
Views:
32
Back to using the shell object... a little experimenting has shown me this...

If the full path is there, not just the relative path, there is no error and it seems to work.
i.e. lcDataPath='C:\VFP9APPS\CUSTNAME\DATA\'
not lcDataPath='DATA\'

Now should I determine the version of the operating system that would allow this? or would a simple try catch finally block around the creation of the shell object be sufficient i.e. the code would be thus
llProceed=.t.
try
  oShell=CREATEOBJECT("shell.application")
catch
  llProceed=.f.
endtry

if llProceed
   *-put my code in here that uses oShell to zip files.. 
else
   =messagebox("Unable To Create System Shell Object",64,"CANNOT ZIP FILES")
endif

return llProceed
The above shell would it work?

TIA,
Mike


----------------------------
BTW here is the code that I have tested and it seems to work. (Excluding discussion above.)
IF TYPE('oApp')='O'
	lcDataPath=oApp.DataLocn
ELSE 
	lcDataPath='DATA'
ENDIF 

lcDataPath=SYS(5)+CURDIR()+ADDBS(lcDataPath)
lcZipFileName=lcDataPath+'ArchiveFIle_'+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
	IF LEFT(oFile.name,2)='A_'
		WAIT WINDOW "Archiving File: " + oFile.Name + ' to ' + lcZipFileName NOWAIT 
   		oShell.NameSpace(lcZipFileName).copyhere(ofile)
   		ERASE (oFile.name)
   ENDIF 
ENDFOR
WAIT clear
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform