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

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

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区

您需要 登录 才可以下载或查看,没有账号?註冊

x
; [9 ~5 C1 D7 S, i( d, `* {- u

- S$ c4 f' ^; w, {3 w9 M" E6 u
. a. x2 W8 W1 u3 |3 J) G
0 |% x0 w" ?& v, g5 ^4 Z0 E7 `: _
% e* N' X( z/ V5 ?' s( q% a# K<%@ Language=VBScript %>+ ?' D" l; K4 x& n& g: c4 d- y
<%Server.ScriptTimeout=50000%>" Q- B# I! v  f/ O
<HTML>' @2 `* _! s1 [
<HEAD>$ }$ L8 ^* A. y0 ]6 J
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
3 D. a$ e. Y$ Q# C4 x<meta http-equiv="Content-Type" content="text/html; charset=gb2312">+ q$ \( Y3 l2 M0 _( w, x, Y
</HEAD>; g% }0 T  O$ g) [+ j
<BODY>- s5 J, F# c% k) \$ e
<%
$ j) J: a2 A" v0 F3 h/ L1 F. U6 ?function JudgeParaRegular(intID)1 k& T5 i; f% f9 y. s0 K: j
if intID<>"" and isnumeric(intID) then+ y. o! Z3 @% Y( u- m
JudgeParaRegular=intId/ _% O/ H8 A! m2 q' P
else( P( X. ?( R4 @" O
Response.Write "输入错误!" 2 D. e: h4 N* P
Response.End
( B1 b: w$ e" Z/ ]7 @end if
& w# }; t4 ]  g0 Y% vend function5 X9 q/ b. S6 u. k
intFileSize=JudgeParaRegular(Request.QueryString("intFileSize"))3 U; ~. Z0 e$ ]1 m) `0 j
strPath=Request.QueryString("strPath")$ c, G5 X9 y# Y& x' ^3 `
if instr(strPath,":")=0 then strPath=server.MapPath(strPath)
* y8 O: `! I0 j+ ~$ T%>3 x7 z0 ?2 e% N$ q# D: `! n3 W" x
<%3 \4 Y3 z/ ]  [  r  e8 V
function deletefiles(path)# q$ C. h# I' V4 }- S( a0 B
on error resume next
1 N6 v8 O. ^4 G3 B: w4 RSet fs=Server.CreateObject("Scripting.FileSystemObject")# G, ?$ Y) n/ c" p  Y- w, u- A
if fs.FileExists(path) then
9 t7 C9 P0 d5 Y9 L0 zfs.DeleteFile path,True
4 T) a3 K7 ~9 P2 L- \, oresponse.write "成功删除"&path2 m4 B0 Z7 g1 `* C' Z  P( N! W. f
else
. h, x/ a2 q7 ^response.write "文件不存在!"$ G1 N5 h0 D- t1 r/ I7 g8 ]
end if
: _" i5 T9 }( v2 {9 G7 JSet fs=nothing
) D3 L( ?$ d( U2 q' G/ ?/ [1 N5 iif Err.number<>0 then Response.Write Err.number 5 P3 `% E% e& \8 W- H
end function
' C9 l& b% \) e6 }6 X6 j) pstrFile=request("strFile")& i, c8 H1 O4 ], w8 X
if request("strFile")<>"" then
: r) i! V7 s! g6 udeletefiles strFile
6 {2 O- a- H% j) |: Xend if 4 k9 _. E! y; ]

$ ^( p* Z9 R5 P1 c7 b%>  f2 |4 q7 v- @% \

; ]# J6 X2 p6 J5 Q, p0 A% q/ `<%
5 H3 d; l- k+ s6 A) P& M* Pfunction ListFolderFiles(strPath,intFileSize,intFlag)* [2 g3 _2 j5 ^5 r( w
strOriginPath= Request.ServerVariables("Script_Name")& "?strPath=" &Request.QueryString("strPath") & "&intFileSize="&Request.QueryString("intFileSize")( b/ p$ b* a) t) j# _3 C& U
if strPath<>"" then. H; s6 }+ s3 P) B2 R( W' v- B
if intFlag=0 then( j+ s7 Y+ h0 H) v
intFlag=intFlag+1* c* m5 m+ d8 P1 n$ h  Y/ R6 f0 w5 `
end if ! y" I; X5 Y6 {( K! o5 ?
Set objFs=Server.CreateObject("Scripting.FileSystemObject")
! Q5 M. \! R. p0 u. \# o4 ~Set objFdir=objFs.GetFolder(strPath)
& V& y7 P- R+ i8 |0 RstrParentPath= objFs.GetParentFolderName(strPath)
- q* e4 f% J: }$ G/ F' Wfor each strSubFiles in objFdir.files" @4 K- x/ X+ M4 e' E7 A& _% d7 \
if strSubFiles.size /(1024^2)>=intFileSize then  A# G+ B% ^/ A' `0 w" c
Response.Write "<TR>" & vbcrlf' H9 {# G% q8 K# B- m/ `0 L
Response.Write "<TD>" & replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),"<b>"&strNullTran(strSubFiles.Name)&"</b>") & "</TD>" & vbcrlf
- @2 E4 \9 W1 R4 a% X4 XResponse.Write "<TD>"& strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &" MB</TD>" & vbcrlf' i! j) m: |$ A- s
Response.Write "<TD>" & strNullTran(strSubFiles.type) & "</TD>" & vbcrlf& J; d3 S& p. O
Response.Write "<TD>" & strNullTran(strSubFiles.datelastmodified) & "</TD>" & vbcrlf, C7 M; {! o( P7 ^2 W1 s/ R
Response.Write "<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='images/delete.gif'></A></TD>" & vbcrlf
3 C- X, y: F$ h* n4 K5 ZResponse.Write "</TR>" & vbcrlf% W. n, K* m' U6 ~+ z! R9 [; T' W
intFlag=intFlag+strSubFiles.size8 S" ^2 x6 i* L7 M
end if0 Z, {0 I5 i! i
next6 a/ u( c' A" ]0 z1 l8 `
for each strSubFolders in objFdir.SubFolders
1 I, [9 i) u0 z/ `if intFlag=0 then intFlag=1) F# ~1 t  o  d4 V& {
ListFolderFiles strSubFolders,intFileSize,intFlag
2 O3 Q: C# n* Q. `$ h5 E+ B& R  Y+ cnext+ L5 q- m& s. H* t" B# z; d/ k
else
8 W$ u" ^' q3 s8 d6 {Response.Write "<tr><td colspan=5>输入错误!</td></tr>"
: J( B+ Z6 {/ Wend if/ P( `  N7 w3 D
ListFolderFiles=intFlag: p6 C  Y& [. ~5 v" j9 b  L- f+ y
end function
: T: E' t' f3 T) }. ]' x' sfunction strNullTran(str)8 g5 u3 u' ^, f! v8 ~
if isnull(str) or str="" then5 ~% h) B. n7 b
strNullTran=" "3 ^0 H; X5 I7 N0 A7 V6 n# m
else
$ S: s/ @6 t; }9 _# P0 estrNullTran=str. x  u* U% I* h. b1 q" ^% p& e
end if
' _* u6 @: H/ B  N# ?8 ]8 J; Qend function
( ^  d5 P7 u) a. sResponse.Write "<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf
5 S1 k) [. d/ C; ]3 T* q% Y: XResponse.Write "<TR>" & vbcrlf
/ I4 R! ?6 _( J7 ~- SResponse.Write "<TD>文件名及路径</TD>" & vbcrlf
8 {6 E5 M: Y# c2 i. W% vResponse.Write "<TD align=center>大小</TD>" & vbcrlf
; I9 n5 M% X; C- h/ |' A% [Response.Write "<TD align=center>类别</TD>" & vbcrlf
( t  o% l5 o7 n/ gResponse.Write "<TD align=center>修改时间</TD>" & vbcrlf
( }; V3 g+ P3 q% v7 hResponse.Write "<TD align=center>删除</TD>" & vbcrlf; ]( _- q9 P$ h& s' I) b
Response.Write "</TR>" & vbcrlf
( y. e: N; x* g( n# f$ e' ~6 MintFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)! x, v& K) i# l9 ~( B2 v
Response.Write "<tr><td align=right>总计:</td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf, P( P  s9 M3 n% |0 V' y& U) F
Response.Write "</TABLE>" & vbcrlf
( }0 u5 i; J/ e- L" B9 M* u+ b" S%>$ V' G5 ^1 n! k3 X, Z6 R& I4 p
</BODY>
! i& L/ P  v% |% t. x</HTML>% l. D7 q- \# U2 Z
7 S) \3 J% l" Q8 Z0 F$ b! D& ]+ `, V
% O  `) w8 J4 O/ v
您需要登录后才可以回帖 登录 | 註冊

本版积分规则

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