Bootstrap

ASP 压缩与解压代码

压缩:

<%
Dim CmdDir,RarNameDir,RarSource
CmdDir=Server.MapPath("dos")&"/" '//cmd.exe和rar.exe存放的路径
RarNameDir=Server.MapPath("data")&"/MMGG" '//压缩为"MMGG.rar"
RarSourceDir=Server.MapPath("data")&"" '//将整个"AA"文件夹压缩
Call Rar(CmdDir,RarNameDir,RarSourceDir)


Sub Rar(ByVal CmdDir,ByVal RarNameDir,RarSourceDir)
   Dim Cmd,Shell
   Cmd=CmdDir&"cmd.exe /c "&CmdDir&"Rar.exe a  -ep1 -o+ " '// -ep1 -o+分别为两个开关命令具体可参考WinRar的帮助
   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 "没有操作Shell权限..."
      Response.End
   End If
   On Error Resume Next
   Shell.Run Cmd,1,True
   If Err Then
      Err.Clear
      Response.Write "压缩文件时出错,可能没有操作权限"
      Response.End
   End If
End Sub
%>

解压:

<%

dim ylj,ywj,Mlpath,Shell,rarcomm,RetCode,cmd,comm,fso

Mlpath=server.MapPath("dos")&"/"    '存放RAR.EXE和CMD.EXE的路径

ylj=Server.mappath("data")&"/"  '解压文件后所放的路径

ywj=Server.MapPath("data")&"/MMGG.rar"  '要解压的RAR文件

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)

%>

;