asp 可否压缩_asp实现在线压缩和解压缩

<

%

'

/

'

/

'

/    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

+

"

"

+

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

"

"

+

s

+

"

"

+

vbCrlf

end Sub

private

sub

callErr(byVal s)

  writeLn

"

ERROR:

"

+

s

  response.End

end sub

private

sub

callSucc(byVal s)

  writeLn

"

SUCCESS:

"

+

s

end Sub

public

sub

compress

  validateFile(sCompressPath)

  oWshShell.run(

"

WinRAR A

"

+

sCompressPath

+

"

"

+

sDecompressPath

&

""

)

if

Err.number

>

0

then

callErr(

"

compress lost!

"

)

  callSucc(

"

compress 

"

+

sDecompressPath

+

"

 to 

"

+

sCompressPath

+

"

.rar 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 

"

+

sCompressPath

+

"

.rar to 

"

+

sDecompressPath

+

"

 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

>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值