跳转到指定楼层   *输入需要访问的楼层直接跳转

使用FSO按文件大小浏览文件目录并进行删除操作

Kiver 发布于2003-11-9 10:39 1004 次浏览 0 位用户参与讨论   [复制分享主题]

; x) m% K0 g- Q, @0 Y- x; b# I" S, y& n7 m3 y
1 d; F7 ]9 J+ a" F6 j4 s
4 x& C4 U1 k, R5 g/ o

" ~8 f- c" }( @- N" \( g# H<%@ Language=VBScript %>
# W* z3 n8 E' H, @' n$ k4 K: F<%Server.ScriptTimeout=50000%>
4 Y. |) j3 ^  d' B<HTML>
% K+ g. W; y: n* G  V0 v<HEAD>" ]- h9 X' e$ q% k' Z0 d
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">9 @+ H4 g) U6 w1 P; {7 B( ?% @- d
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">. G3 E1 t! p2 J( e! Q. U# {8 V5 N# \
</HEAD>/ b% R( J: t7 h$ O
<BODY>
8 H2 U& p8 W( K9 ^- h<%8 ~; R/ h9 d- h
function JudgeParaRegular(intID)1 \  o, d. z2 `0 u8 S9 w5 s& q# ~
if intID<>"" and isnumeric(intID) then+ x# O; W! F2 m" ~- Y+ {
JudgeParaRegular=intId. b+ F. B7 A; z2 n& W) j% N
else* e% A9 h5 |9 y* ^* `" f' P" q' R
Response.Write "输入错误!"
8 X3 ~" M5 J. J' \3 }# N' n/ `3 |  LResponse.End   k/ d: c5 ?  V# }% F, Y
end if
( v1 ?2 Y" ~7 y; a0 ~, p" e0 Yend function1 a( r2 D6 l' W, |4 H) P2 a
intFileSize=JudgeParaRegular(Request.QueryString("intFileSize"))4 M& X$ B- b% p$ I; {$ i) l. m' O9 F: [% Z
strPath=Request.QueryString("strPath")2 m; H& X9 d& p" `9 T
if instr(strPath,":")=0 then strPath=server.MapPath(strPath)
+ C+ W* O5 f+ H%>; l: o( Q7 `4 L( `+ y
<%" k3 Y+ M' o: E0 W& `/ F* @, o
function deletefiles(path)
* D5 A6 J7 H" mon error resume next" V6 O) a, |! }  u, z
Set fs=Server.CreateObject("Scripting.FileSystemObject")
5 O- j( p1 i+ x) h; Y4 yif fs.FileExists(path) then
( ~! G: Y$ c9 G# H; N9 k* |! _fs.DeleteFile path,True$ y- G  v9 O. o9 O
response.write "成功删除"&path) {, }2 Z# y7 l8 y' t
else: `4 U1 B. r: ]! K
response.write "文件不存在!"
, d  O2 n  C' ^5 J8 b) b' y1 Nend if
' U) L( W' P. }% I: Y, C5 ?Set fs=nothing
! `. R' v6 x6 h  Sif Err.number<>0 then Response.Write Err.number
. f" x6 ~0 `+ v  c: D/ u% Kend function+ z. T' I( n5 K* B" G
strFile=request("strFile")6 x8 }! g) X% \/ M
if request("strFile")<>"" then# X; T& D* T" i/ H3 k  I9 v
deletefiles strFile( w0 {; C+ S+ K+ H" p$ L" s
end if 8 ]/ O  }) s/ S' i. _
7 Q* ^1 @- N5 ~# j6 E" u0 o
%>
& N# A2 \/ H2 ]1 _9 u, c9 S; I7 @1 |6 t
<%$ A% O# e/ G# B6 Y7 z0 m0 P' K( F$ y
function ListFolderFiles(strPath,intFileSize,intFlag)' H0 I4 }2 w6 y) f/ o. ^0 i
strOriginPath= Request.ServerVariables("Script_Name")& "?strPath=" &Request.QueryString("strPath") & "&intFileSize="&Request.QueryString("intFileSize")
+ \7 m7 {! r  A$ q" V! n) M: E8 w1 Gif strPath<>"" then
: ?: _& a0 f: Z$ tif intFlag=0 then
% L+ P5 Q5 x8 F+ ZintFlag=intFlag+10 G% |& H- X% B
end if
/ V" b1 z0 P. Y, JSet objFs=Server.CreateObject("Scripting.FileSystemObject")/ c7 R7 }+ L* t2 u/ i7 e
Set objFdir=objFs.GetFolder(strPath), [/ e% t2 c; _+ I
strParentPath= objFs.GetParentFolderName(strPath)
' q- o2 O# Q3 J  V. {% X& f8 [for each strSubFiles in objFdir.files
' F. C& x. ?* E8 Nif strSubFiles.size /(1024^2)>=intFileSize then! L: ]; k9 t: z; S" E9 P
Response.Write "<TR>" & vbcrlf
7 `5 v3 |! _$ }Response.Write "<TD>" & replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),"<b>"&strNullTran(strSubFiles.Name)&"</b>") & "</TD>" & vbcrlf
% M/ E9 _3 m% P' n' U4 ?Response.Write "<TD>"& strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &" MB</TD>" & vbcrlf
- M$ D# E3 b7 |/ _* nResponse.Write "<TD>" & strNullTran(strSubFiles.type) & "</TD>" & vbcrlf/ g1 x# B9 C2 T& r. U
Response.Write "<TD>" & strNullTran(strSubFiles.datelastmodified) & "</TD>" & vbcrlf& _2 Z* C* ~( d9 p2 s
Response.Write "<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='images/delete.gif'></A></TD>" & vbcrlf
: |, Z  H. X7 v& VResponse.Write "</TR>" & vbcrlf
! J; I7 [) _- O0 _- l$ }) B' r( [intFlag=intFlag+strSubFiles.size4 {; ], w: F; \$ A4 p6 f* q. @8 m
end if; w) F  b% F) I! G7 R2 V5 o
next7 e1 ]7 H) E+ r
for each strSubFolders in objFdir.SubFolders5 G+ L' h# F9 P( t" b9 o# N$ z4 p
if intFlag=0 then intFlag=13 B4 @" Q& M* o" j9 m# z) _
ListFolderFiles strSubFolders,intFileSize,intFlag9 @* D  H4 N. V% ^6 z1 s- `
next0 s9 X8 b8 f; T
else
3 ]! F1 o% ^3 S7 tResponse.Write "<tr><td colspan=5>输入错误!</td></tr>"( _3 g; L' _% C' Q
end if
$ l, `) s; Y. ~% n% o+ b6 nListFolderFiles=intFlag
$ b% a* E$ w* l3 p) p, L" n9 kend function* w- W0 P. b. U* B9 k3 W* O
function strNullTran(str)
6 k: p* R/ A- J* h! o1 Rif isnull(str) or str="" then
5 S, C; l; w, o  H; V0 _3 o% K: h( jstrNullTran=" "
& u3 a9 j: `6 v8 C3 h8 yelse
/ ^6 M4 r% z' g" A1 j; `strNullTran=str
- Z+ R  C* @$ O" u* a* N5 N% u5 j& jend if5 w" F: B6 _% E
end function 1 X$ [$ f. d' c) j# T; F$ X
Response.Write "<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf) I/ E5 ]4 L; @. c, U
Response.Write "<TR>" & vbcrlf2 o9 c- M: n( W2 n1 {" b4 j6 u
Response.Write "<TD>文件名及路径</TD>" & vbcrlf- ~8 T% q3 Z5 u: x$ U% D+ b
Response.Write "<TD align=center>大小</TD>" & vbcrlf2 |5 ^) Y, s( O5 l; k- B  ]
Response.Write "<TD align=center>类别</TD>" & vbcrlf9 g( L0 x+ i4 ]1 \* Y
Response.Write "<TD align=center>修改时间</TD>" & vbcrlf
7 @1 O' ^4 M* ?4 ^& [# G# IResponse.Write "<TD align=center>删除</TD>" & vbcrlf" j/ `6 K: l6 g' L+ C
Response.Write "</TR>" & vbcrlf; D( t0 C; h7 f! A, W9 E* M* |5 u  y* H
intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)
$ ^. P' d6 a) A; Y+ H2 EResponse.Write "<tr><td align=right>总计:</td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf
0 o, a2 v8 D2 k! xResponse.Write "</TABLE>" & vbcrlf+ b. f( P4 y0 {
%>
- N) ]9 }! \* @6 H9 G</BODY>1 e$ B5 W% g! ?* ~# U  K6 |; p
</HTML>/ M: Z+ p, z' m) K1 t
! o0 |4 z1 M  o. z& I- M

$ ]8 U- W2 ]& l! k' E2 P+ S& C- ^
您需要登录后才可以回帖 登录 | 註冊

本版积分规则

快速
回复
返回
列表
返回
顶部