[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

vb.net zip help needed

I am trying to extract, zip and download.  I have an open question on this.  However, I have finaly gotten to a point where I can get most of the work done, for zip part after searching number of ways, I found I can do cmd.exe shell to use zip.  I do not know much about it.  There is a site for zip 3.0 with open source code.  In any case, I get the zip to work on the server that I am developing on.  However that is using hardcoded drive/folder locations.  When I move to production it does not work.  I do not know if I can and how to use virtual path on the cmd.exe and/or zip command.  I have sample command below that works on developer machine.  can anyone help me make this code work on production server, basically point me in direction where I can switch this to virtual path.
Thanks


=====================================================
'I need server.MapPath or some similar command below I believe, not sure what is proper format...
Dim zipcmd As String = "zip -q -r -j C:\abc\SQLRESULTS\SQLRESULTS.zip C:\abc\SQLRESULTS"
Shell("cmd.exe /c /k cd C:\abc\SQLRESULTS\" + zipcmd, AppWinStyle.Hide, True)

'below code works fine;
Response.ContentType = "application/x-zip-compressed"
Response.AppendHeader("Content-Disposition", "attachment; filename=abc.zip")
Response.TransmitFile(Server.MapPath("~/SQLRESULTS/SQLRESULTSxxx.zip"))
Response.End()
0
CPOINT2000
Asked:
CPOINT2000
  • 4
  • 3
1 Solution
 
CodeCruiserCommented:
Have you looked at programmatic zipping or is that out of question?

http://www.icsharpcode.net/opensource/sharpziplib/

http://dotnetzip.codeplex.com/
0
 
CPOINT2000Author Commented:
I am looking for simple way as possible.  I have been looking into dotnetzip, I am assuming I can use virtual folders or URL address where the zip is created?  I am short on time, and don't have too much time to download and try all thats out there.  I will look into dotnetzip.  The method I used works fine on local server, is it possible to use zip 3.0 that I have on my server with cmd.exe as I asked?  Can I incorporate server.MapPath to that command somehow?
0
 
CPOINT2000Author Commented:
I am not sure I understand what exactly I need from dotnetzip package.  the download zip package has tons of files.  As I said I do not have time to learn another package.  Any one if I can use the zip package (zip 3.0) that I have explained above?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
CodeCruiserCommented:
Yes you can use server.mappath to translate virtual path to physical path.

Are you using shared hosting?
0
 
CPOINT2000Author Commented:
Yes.

Also how would I use virtual path in this line?  what is the syntax?
Dim zipcmd As String = "zip -q -r -j C:\abc\SQLRESULTS\SQLRESULTS.zip C:\abc\SQLRESULTS"


another part of code I have the following and it works;
Response.TransmitFile(Server.MapPath("~/SQLRESULTS/SQLRESULTSxxx.zip"))
0
 
CodeCruiserCommented:
>Yes

Given that you are using shared hosting, you would only be able to access folders/files within your website directory. Forget about c:\abc or consider ~/SQLRESULTS/SQLRESULTSxxx.zip as the only option. Also, I am not sure if you would be able to execute shell commands in a shared environment.
0
 
CPOINT2000Author Commented:
sharpziplib did the trick for me.  and thanks for answering my other questions regarding cmd.exe path etc...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now