WEB开发网
开发学院WEB开发ASP asp实现在线压缩和解压缩 阅读

asp实现在线压缩和解压缩

 2008-08-31 12:54:23 来源:WEB开发网   
核心提示:好久没来看看blog了,写了个简单的东西,asp实现在线压缩和解压缩,希望对大家有用附带实例<%'\\\'\\'\\ 1. c:\windows\system32\cmd.exe'\\ 拷贝把本文件所在的路径'\\'\\ 2. 把 c:\program\winr

好久没来看看blog了,写了个简单的东西,希望对大家有用

附带实例

<%
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\   1. c:\windows\system32\cmd.exe
'\\    拷贝把本文件所在的路径
'\\
'\\   2. 把 c:\program\winrar\rar.exe
'\\    拷贝把本文件所在的路径 并改名为WinRAR.exe
'\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\
'\\   compressPath(byVal s)
'\\   压缩文件的路径 | 字符串变体
'\\
'\\   decompressPath(byVal s)
'\\   解压缩文件的文件夹 | 字符串变体
'\\
'\\   compress
'\\   在线压缩
'\\
'\\   decompress
'\\   在线解压缩
'\\
'\\   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!")

Tags:asp 实现 在线

编辑录入:coldstar [复制链接] [打 印]
赞助商链接