never-online 's Tech Blog In CSDN

never online - Everlasting love for angela.

用户操作
[即时聊天] [发私信] [加为好友]
never-onlineID:BlueDestiny
157478次访问,排名512,好友17人,关注者36人。
在京城
BlueDestiny的文章
原创 114 篇
翻译 0 篇
转载 8 篇
评论 246 篇
never-online的公告
Web:
www.never-online.net
Email:
BlueDestiny##126.com
QQ:
77091373
最近评论
liseo1:
网络营销策划 网络公关 品牌管理 搜索引擎危机公关 搜索引擎排名 网站优化 软文发布 QQ:297261337 手机:13701171386
堆高车
堆垛车
liseo1:
网络营销策划 网络公关 品牌管理 搜索引擎危机公关 搜索引擎排名 网站优化 软文发布 QQ:297261337 手机:13701171386
堆高车
堆垛车
liseo1:
网络营销策划 网络公关 品牌管理 搜索引擎危机公关 搜索引擎排名 网站优化 软文发布 QQ:297261337 手机:13701171386
堆高车
堆垛车
liseo1:
网络营销策划 网络公关 品牌管理 搜索引擎危机公关 搜索引擎排名 网站优化 软文发布 QQ:297261337 手机:13701171386
堆高车
堆垛车
liseo1:
网络营销策划 网络公关 品牌管理 搜索引擎危机公关 搜索引擎排名 网站优化 软文发布 QQ:297261337 手机:13701171386
堆高车
堆垛车
文章分类
收藏
相册
icon
JS & DHTML
Dhteumeuleu
Douglas Crockford
Webfx
常去之地
ASP.Net
MSDN英文
XML指南
XML的大本营
博客园
正则表达式
我的网站
我网站的Blog(RSS)
友情链接
KimSoft的blog(RSS)
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 asp实现在线压缩和解压缩收藏

新一篇: 小工具:计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节 | 旧一篇: HOW TO: Optimize Web Server Performance in Windows 2000 and windows2003 msdn

好久没来看看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!")
  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>

发表于 @ 2005年10月16日 01:16:00|评论(loading...)|编辑

新一篇: 小工具:计算当前文件夹中,有多少行JS代码和ASP代码,并且还可统计代码有多少字节 | 旧一篇: HOW TO: Optimize Web Server Performance in Windows 2000 and windows2003 msdn

评论

#kingpwf 发表于2006-01-09 13:38:00  IP: 61.173.28.*
怎么压不了啊?
QQ:31874445
MSN:kingpwf@hotmail.com
#爱好者 发表于2006-03-01 09:25:00  IP: 221.237.182.*
你好,看了你写的例子,有一个问题请教:比如程序放在D:\a\b\c\d目录中,那么压缩d目录中的一个名为A.doc的文件时,最终得到的压缩包中的路径会是a\b\c\d\A.doc,使用什么方法可以使得最终压缩包中的路径直接是A.doc文件而不包括前面的文件夹路径呢?
盼赐教,谢谢。
#bluedestiny 发表于2006-03-02 00:30:00  IP: 58.82.47.*
@爱好者

我没仔细的研究这个问题,现在觉得解决办法两个:

1。看winrar的开关命令。
2。FSO copy文件到当前目录再执行打包。(这个办法不可取)
#爱好者 发表于2006-03-06 08:59:00  IP: 221.237.182.*
谢谢回复。
看了rar的开关命令,根据其例子中好象可以不用以盘符开始,但在ASP文件中实际操作中压缩文件路径如果不以盘符开始则无效,不知有无其他解决办法?
:(
#爱好者 发表于2006-03-06 09:04:00  IP: 221.237.182.*
另外,你说的第二种办法,即使把文件拷到当前目录,但如果当前目录不是在盘符根目录下,仍会包含其他路径,如当前目录为D:\A\B\C目录中,压缩后仍会包括A\B\C文件夹。
发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © never-online