We help IT Professionals succeed at work.

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()
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Have you looked at programmatic zipping or is that out of question?

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

http://dotnetzip.codeplex.com/

Author

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?

Author

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?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

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

Are you using shared hosting?

Author

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"))
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
>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.

Author

Commented:
sharpziplib did the trick for me.  and thanks for answering my other questions regarding cmd.exe path etc...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.