看到asp版好像冷清了点,写了个简单的东西,希望对大家有用 asp在线压缩和解压缩文件(文件夹)

BlueDestiny 2005-10-17 09:00:37
asp在线压缩和解压缩文件(文件夹)
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ 1. c:\windows\system32\cmd.exe
'\\ 拷贝把本文件所在的路径
'\\
'\\ 2. 把 c:\program\winrar\rar.exe
'\\ 拷贝把本文件所在的路径 并改名为WinRAR.exe
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ compressPath(byVal s)
'\\ 压缩文件的路径 | 字符串变体
'\\
'\\ decompressPath(byVal s)
'\\ 解压缩文件的文件夹 | 字符串变体
'\\
'\\ compress
'\\ 在线压缩 | sub
'\\
'\\ decompress
'\\ 在线解压缩 | sub
'\\
'\\ POWER BY MIRACLE (BLUEDESTINY)
'\\
'\\ EMAIL : Bluedestiny[at]126.com
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

OPTION EXPLICIT

class COMPRESS_DECOMPRESS_FILES

private version, copyright
private oWshShell, oFso
private sCompressPath, sDecompressPath

private sub class_initialize
version="COMPRESS_DECOMPRESS_FILES BUILDER 20051015"
copyright="POWER BY MIRACLE (BLUEDESTINY)"
Set oFso=server.CreateObject("scripting.FileSystemObject")
Set oWshShell=server.CreateObject("Wscript.Shell")
writeLn(version+"<br>"+copyright)
end Sub
private sub class_terminate
if isobject(oWshShell) then set oWshShell=nothing
if isobject(oFso) then set oFso=nothing
end Sub
private function physicalPath(byVal s)
physicalPath=server.mappath(s)
end Function
private sub validateFile(byVal s)
if oFso.FileExists(s) then exit sub
if oFso.FolderExists(s) then exit sub
callErr "file(folder) not exists!"
end Sub
private sub createFolder(byVal s)
if oFso.FolderExists(s) then exit Sub
oFso.createFolder(s)
end Sub
private sub writeLn(byVal s)
response.write "<p>" + s + "</p>" + vbCrlf
end Sub
private sub callErr(byVal s)
writeLn "<p><b>ERROR:</b></p>" + s
response.End
end sub
private sub callSucc(byVal s)
writeLn "<p><b>SUCCESS:</b></p>" + s
end Sub

public sub compress
validateFile(sCompressPath)
oWshShell.run("WinRAR A " + sCompressPath + " " + sDecompressPath & "")
if Err.number>0 then callErr("compress lost!")
callSucc("compress <b>" + sDecompressPath + "</b> to <b>" + sCompressPath + ".rar</b> successfully!")
end Sub
public sub decompress
validateFile(sCompressPath)
createFolder(sDecompressPath)
oWshShell.run("WinRAR X " + sCompressPath + " " + sDecompressPath & "")
if Err.number>0 then callErr("decompress lost!")
callSucc("decompress <b>" + sCompressPath + ".rar</b> to <b>" + sDecompressPath + "</b> successfully!")
end sub

public property Let compressPath(byVal s)
sCompressPath=physicalPath(s)
end property
public property Let decompressPath(byVal s)
sDecompressPath=physicalPath(s)
end property

End class
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
* {
font-size:10.2pt;
font-family:tahoma;
}
</style>
</HEAD>

<BODY>
<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ 设有压缩文件 compress.rar
'\\ 需压缩文件 decompressFolder 文件夹
'\\
'\\ 将 compress.rar 解压缩至 1 文件夹
'\\ 将 decompressFolder 文件夹 压缩至 2.rar
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

dim oExample

set oExample=new COMPRESS_DECOMPRESS_FILES
oExample.compressPath="decompressFolder"
oExample.decompresspath="1"
oExample.compress

oExample.compressPath="compress.rar"
oExample.decompresspath="2"
oExample.decompress

set oExample=nothing
%>
</BODY>
</HTML>
...全文
2140 73 打赏 收藏 转发到动态 举报
写回复
用AI写文章
73 条回复
切换为时间正序
请发表友善的回复…
发表回复
mhxz5680 2006-05-09
  • 打赏
  • 举报
回复
只想MARK
kingpwf 2006-01-09
  • 打赏
  • 举报
回复
我怎么不能用了,压不了啊
那位老大给给文件啊?
QQ:31874445
MSN:kingpwf@hotmail.com
wj2929 2005-12-24
  • 打赏
  • 举报
回复
有空格是怎么解决?
我前段时间也曾写过跟楼主相关的代码
虽然用fso的shortpath获取到短路径直接在dos下运行成功 但在asp中调用cmd执行rar操作死活有问题
不知何故
shef66 2005-12-24
  • 打赏
  • 举报
回复
谢了,楼主,先收下先
fox1999 2005-12-22
  • 打赏
  • 举报
回复
没什么用。一般服务器不可能给开这个权限的。

要不你上传个本马,不把服务器黑了?
wzhiyuan 2005-12-20
  • 打赏
  • 举报
回复
mark
dhluo 2005-12-20
  • 打赏
  • 举报
回复
学习
zwrtv 2005-12-14
  • 打赏
  • 举报
回复
学习下
dcyuan480 2005-12-14
  • 打赏
  • 举报
回复
支持原创,顶!
zgengle 2005-12-14
  • 打赏
  • 举报
回复
mark一下
patchclass 2005-12-08
  • 打赏
  • 举报
回复
虽然见过很多,不过还是感谢楼主分享
server.CreateObject("Wscript.Shell")
要的权限太高了啊
ljqhbt 2005-12-08
  • 打赏
  • 举报
回复
选收藏了
chinastorm 2005-12-06
  • 打赏
  • 举报
回复
mark
niehuihui 2005-11-28
  • 打赏
  • 举报
回复
支持~~好东西~~收藏~~
yjbnew 2005-11-28
  • 打赏
  • 举报
回复
mark
  • 打赏
  • 举报
回复
支持一下!
mzcih 2005-11-27
  • 打赏
  • 举报
回复
要装什么客户端软件吗?
xiaoxingchi 2005-11-25
  • 打赏
  • 举报
回复
mylove36 2005-11-24
  • 打赏
  • 举报
回复
学习学习
ken2002 2005-11-24
  • 打赏
  • 举报
回复
收藏了
加载更多回复(53)

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧