asp实现在线压缩和解压缩

附带实例

< %
' \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
\
'
\1.c:windows\system32\cmd.exe
'
\拷贝把本文件所在的路径
'
\
'
\2.把c:program\winrar\rar.exe
'
\拷贝把本文件所在的路径并改名为WinRAR.exe
'
\
'
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
\
'
\compressPath(byVals)
'
\压缩文件的路径|字符串变体
'
\
'
\decompressPath(byVals)
'
\解压缩文件的文件夹|字符串变体
'
\
'
\compress
'
\在线压缩
'
\
'
\decompress
'
\在线解压缩
'
\
'
\POWERBYMIRACLE(BLUEDESTINY)
'
\
'
\EMAIL:Bluedestiny[at]126.com
'
\
'
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

OPTION EXPLICIT

classCOMPRESS_DECOMPRESS_FILES

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

private sub class_initialize
version
= " COMPRESS_DECOMPRESS_FILESBUILDER20051015 "
copyright
= " POWERBYMIRACLE(BLUEDESTINY) "
Set oFso = server.CreateObject( " scripting.FileSystemObject " )
Set oWshShell = server.CreateObject( " Wscript.Shell " )
writeLn(version
+ " <br> " + copyright)
endSub
private sub class_terminate
if isobject (oWshShell) then set oWshShell = nothing
if isobject (oFso) then set oFso = nothing
endSub
private function physicalPath(byVals)
physicalPath
= server.mappath(s)
endFunction
private sub validateFile(byVals)
if oFso.FileExists(s) then exit sub
if oFso.FolderExists(s) then exit sub
callErr
" file(folder)notexists! "
endSub
private sub createFolder(byVals)
if oFso.FolderExists(s) then exit Sub
oFso.createFolder(s)
endSub
private sub writeLn(byVals)
response.write
" <p> " + s + " </p> " + vbCrlf
endSub
private sub callErr(byVals)
writeLn
" <p><b>ERROR:</b></p> " + s
response.End
endsub
private sub callSucc(byVals)
writeLn
" <p><b>SUCCESS:</b></p> " + s
endSub

public sub compress
validateFile(sCompressPath)
oWshShell.run(
" WinRARA " + sCompressPath + " " + sDecompressPath & "" )
if Err.number > 0 then callErr( " compresslost! " )
callSucc(
" compress<b> " + sDecompressPath + " </b>to<b> " + sCompressPath + " .rar</b>successfully! " )
endSub
public sub decompress
validateFile(sCompressPath)
createFolder(sDecompressPath)
oWshShell.run(
" WinRARX " + sCompressPath + " " + sDecompressPath & "" )
if Err.number > 0 then callErr( " decompresslost! " )
callSucc(
" decompress<b> " + sCompressPath + " .rar</b>to<b> " + sDecompressPath + " </b>successfully! " )
endsub

public property Let compressPath(byVals)
sCompressPath
= physicalPath(s)
endproperty
public property Let decompressPath(byVals)
sDecompressPath
= physicalPath(s)
endproperty

End class
%
>
< !DOCTYPEHTML PUBLIC " -//W3C//DTDHTML4.0Transitional//EN " >
< HTML >
< HEAD >
< TITLE > New Document </ TITLE >
< METANAME = " Generator " CONTENT = " EditPlus " >
< METANAME = " Author " CONTENT = "" >
< METANAME = " Keywords " CONTENT = "" >
< METANAME = " 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 >

你可能感兴趣的:(C++,c,windows,C#,asp)