欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ASP解压缩(在线解压缩类)

程序员文章站 2023-10-20 23:02:46
复制代码 代码如下:<% '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ '\\ '\\&n...
复制代码 代码如下:

<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ 1. c:\windows\system32\cmd.exe
'\\ 拷贝把本文件所在的路径
'\\
'\\ 2. 把 c:\program\winrar\rar.exe
'\\ 拷贝把本文件所在的路径 并改名为winrar.exe
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\ compresspath(byval s)
'\\ 压缩文件的路径 | 字符串变体
'\\
'\\ decompresspath(byval s)
'\\ 解压缩文件的文件夹 | 字符串变体
'\\
'\\ compress
'\\ 在线压缩
'\\
'\\ decompress
'\\ 在线解压缩
'\\
'\\ power by never-online
'\\
'\\ 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> asp在线解压缩 </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"
oexample.decompresspath="2"
oexample.decompress

set oexample=nothing
%>
</body>
</html>