需求:在ASP里压缩上传后的文件。先上传后,然后压缩文件,然后把原来的文件删除。

下面是看了别人的,自己总计的东西。

<%

on error resume next
unzip_path=Server.mappath("..\rar\")&"\"
Set WshShell = server.CreateObject("Wscript.Shell")
Response.write  unzip_path
'压缩后删除原来文件。a:表示创建  -m5  表示最好的压缩(慢) -df  表示压缩成功后原来文件删除
'IsSuccess = WshShell.Run ("winrar  a -m5 -df "&unzip_path&"测试文件.doc.rar  "&unzip_path&"测试文件.doc")     '
'-ap24v.com.cn  -ap为压缩文件指定目录 -ep 表示不保留原来的路径(如果没有这个参数那么,压缩文件打开后会看到里面的目录结构就是压缩前文件的绝对路径)
'IsSuccess = WshShell.Run ("winrar  a  -ap24v.com.cn   -ep   "&unzip_path&"bb.mdb.rar  "&unzip_path&"bb.mdb" )
'-压缩多个文件,指定压缩文件目录结构,删除原来的文件
IsSuccess = WshShell.Run ("winrar  a  -m5 -df -ap24v.com.cn   -ep   "&unzip_path&"bb.mdb.rar  "&unzip_path&"bb.mdb " &unzip_path&"24v.com.cn.html" )
'压缩多个文件
'IsSuccess = WshShell.Run ("winrar a "&unzip_path&"测试文件.doc.rar  "&unzip_path&"测试文件.doc "&unzip_path&"测试文件2.doc " &unzip_path&"24v.com.cn.html")
if IsSuccess = 0 Then
Response.write " 命令成功执行!"
else
Response.write " 命令执行失败!权限不够或者该程序无法运行"
end if
if err.number <> 0 then
Response.Write "<p>错误号码:" & Err.number
Response.Write "<p>原因:" & Err.description
Response.Write "<p>错误来源:" & Err.Source
Response.Write 
end if
%>