ASP compression and decompression code

Source: Internet
Author: User

Compression:

<%
Dim quota Dir, rarnamedir, rarsource
Export dir = server. mappath ("dos") & "/" '// The storage path of pai.exeand rar.exe
Rarnamedir = server. mappath ("data") & "/mmgg" '// compress to "mmgg.rar"
Rarsourcedir = server. mappath ("data") & "'// compress the entire" AA "folder
Call RAR (includir, rarnamedir, rarsourcedir)

Sub RAR (byval includir, byval rarnamedir, rarsourcedir)
Dim cmd, Shell
Cmd = cmddir & "cmd.exe/C" & cmddir & "rar.exe A-EP1-O +" '//-EP1-O + each has two switch commands. For details, refer to WinRAR help.
Cmd = cmd & rarnamedir & "& rarsourcedir
On Error resume next
Set shell = server. Createobject ("wscript. Shell ")
If err or isobject (Shell) = false then
If err then err. Clear
Response. Write "no shell operation permission ..."
Response. End
End if
On Error resume next
Shell. Run cmd, 1, true
If err then
Err. Clear
Response. Write "An error occurred while compressing the file. You may not have operation permissions"
Response. End
End if
End sub
%>

Decompress:

<%

Dim ylj, ywj, mlpath, Shell, rarcomm, retcode, CMD, comm, FSO

Mlpath = server. mappath ("dos") & "/" 'stores RAR. EXE and cmd. EXE paths

Ylj = server. mappath ("data") & "/" 'path after extracting the file

Ywj = server. mappath ("data") & "/mmgg.rar" 'The rarfile to be decompressed

Set shell = server. Createobject ("wscript. Shell ")

Rarcomm = mlpath & "cmd.exe/C" & mlpath & "rar.exe X-T-O +-p -"

Cmd = rarcomm & ywj & "& ylj

Retcode = shell. Run (CMD, 1, false)

%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.