Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


NameSpace doesn't like zip file in ASP

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,58017
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> NameSpace doesn't like zip file in ASP
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 NameSpace doesn't like zip file in ASP - 3/17/2008 3:20:05 AM   
  amallen9867

 

Posts: 4
Score: 0
Joined: 3/17/2008
Status: offline

I have a vbscript that creates an empty zip file and then loads a couple of files into it for eventual download. As a stand-alone vbscript it works fine but when I add the code to an ASP page the code chokes on the NameSpace object. So I can create the empty zip file but I can't add any files to it.

Here's the code:
Dim zipFile, objFSO, objTxt, objApp
zipFile = "D:\ArcIMS\Output\SavedMapImages\aaa.zip" 'The path and name of your zip file

'Create an empty ZIP file
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTxt = objFSO.OpenTextFile(zipFile, 2, True)
objTxt.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, Chr(0))
objTxt.Close

'Copy the files into the ZIP file
Set objApp = Server.CreateObject("Shell.Application")
objApp.NameSpace(zipFile).CopyHere("D:\ArcIMS\Output\SavedMapImages\aaa.png ")
objApp.NameSpace(zipFile).CopyHere("D:\ArcIMS\Output\SavedMapImages\aaa.pgw ")

It's the NameSpace object in the last two lines that throw errors. And it's the zip file itself that causes the error; I don't get an error if I use a basic folder path.

Does anybody have a solution?

Thanks,

amallen
 
 
Post #: 1
 
 RE: NameSpace doesn't like zip file in ASP - 3/18/2008 3:17:58 AM   
  webber123456

 

Posts: 32
Score: 0
Joined: 9/20/2007
Status: offline
I doubt you can call the shell object from ASP because of security reasons.

(in reply to amallen9867)
 
 
Post #: 2
 
 RE: NameSpace doesn't like zip file in ASP - 3/18/2008 3:47:32 AM   
  amallen9867

 

Posts: 4
Score: 0
Joined: 3/17/2008
Status: offline
webber123456 (or anyone else),

Could I call a VBScript file from the VBScript within the ASP file to execute the code that adds files to the zip file? Might that get around the security issue?

If not, do you have any suggestions how I might add files to an empty zip file via ASP? That's my end goal.

Thanks,

amallen9867

(in reply to webber123456)
 
 
Post #: 3
 
 RE: NameSpace doesn't like zip file in ASP - 3/19/2008 7:02:58 AM   
  TNO


Posts: 974
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
In my experience, its always been safest to keep files in relative locations instead of complete paths on the server. Also, any time you are doing something with file locations, try to use MapPath

_____________________________

Consolidated Script Component: Now in Testing stage!

A universe of complexity...

(in reply to amallen9867)
 
 
Post #: 4
 
 RE: NameSpace doesn't like zip file in ASP - 3/19/2008 7:47:28 AM   
  amallen9867

 

Posts: 4
Score: 0
Joined: 3/17/2008
Status: offline
Good advice above. I will keep that in mind for the final version.

Now for the big question(s): How do I add files to an empty zip file using vbscript in an ASP page? Can I do so using MapPath? Any other way?

amallen9867

(in reply to amallen9867)
 
 
Post #: 5
 
 RE: NameSpace doesn't like zip file in ASP - 3/19/2008 9:59:34 AM   
  TNO


Posts: 974
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Perhaps this: http://classicasp.aspfaq.com/general/how-do-i-zip/unzip-files-from-asp.html

If the application is local you don't have to worry about <path> variables and all that crap. (referring to the pkzip)

_____________________________

Consolidated Script Component: Now in Testing stage!

A universe of complexity...

(in reply to amallen9867)
 
 
Post #: 6
 
 RE: NameSpace doesn't like zip file in ASP - 4/18/2008 1:46:01 AM   
  amallen9867

 

Posts: 4
Score: 0
Joined: 3/17/2008
Status: offline
Thanks for the above posts. I ended up using XZip as my zip utility (http://xstandard.com/en/documentation/xzip/). Just install the dll somewhere and register it using regsvr32.

Below is a code snippet for anyone interested. It's a working copy (but it does work!). I still have to clean it up using relative paths and MapPath.

   'Initialize stuff for zip file
   Dim folderPath, zipFilePath, fsoZipFile, fsoTxtFile, objZip
   folderPath = "D:\wherever\" 'The path to the files to be zipped
   zipFilePath = folderPath + "myzipfile.zip" 'The path and name of the zip file

   'Create an empty ZIP file
   Set fsoZipFile = Server.CreateObject("Scripting.FileSystemObject")
   Set fsoTxtFile = fsoZipFile.OpenTextFile(zipFilePath, 2, True)
   fsoTxtFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, Chr(0))
   fsoTxtFile.Close

   'Copy files into the ZIP file
   Set objZip = Server.CreateObject("XStandard.Zip")
   objZip.Pack folderPath + "filename.png", zipFilePath
   objZip.Pack folderPath  + "filename.pgw", zipFilePath

amallen9867

(in reply to TNO)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> NameSpace doesn't like zip file in ASP Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts