- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6984
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1840
- 精华
- 6
- 积分
- 15415
- 阅读权限
- 200
- UID
- 10
   
- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6984
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1840
- 精华
- 6
- 积分
- 15415
- 阅读权限
- 200
- UID
- 10
|
ASP文件操作大全
8 x- ?8 q2 Q: B<% k$ h( Y! R/ D# I# j- {) i
Class Cls_FSO ; H6 s1 d2 p2 R$ v- O( d
Public objFSO
1 a; o1 e/ F1 X; H1 w/ SPrivate Sub Class_Initialize()
9 O( _+ r# X( z4 L+ z+ S2 d7 v, \0 U' VSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
/ D- \6 I& |1 S& v1 U, a+ SEnd Sub
: s% B3 g; c" kPrivate Sub class_terminate() , {% r7 C# K' D+ p$ [" S8 A
Set objFSO = Nothing 9 W( a, g: I6 c- u( N
End Sub
/ n! S3 L$ t; z N7 o3 K) w$ _& g5 V0 _% L) B& g% {+ p
'=======文件操作======== ! y7 \; d# v4 S
'取文件大小
n" s5 O0 t- r# U* \" tPublic Function GetFileSize(FileName)
; R' _+ U) b9 GDim f
& b1 T h4 i2 D' LIf ReportFileStatus(FileName) = 1 Then
: r9 p* h% J- o% [7 fSet f = objFSO.Getfile(FileName)
8 q3 q7 m" l& y4 O \7 C/ _GetFileSize = f.Size
% Y1 Y1 K, P* d& y8 [% R: h( mElse % [$ Y, e$ Z: u
GetFileSize = -1
! m8 M* e/ l( v" ZEnd if & R: T; U% i7 I- ]9 V
End Function
8 \8 k4 q) T9 }
: z5 [2 M& }( B1 M'文件删除 8 x! f9 y) }* f! c
Public Function deleteAFile(FileSpec)
0 y& `6 ^, Y3 n# eIf ReportFileStatus(FileSpec) = 1 Then
, s2 |5 A& `) H6 ~" o" {2 _% O" @" V6 ZobjFSO.deleteFile(FileSpec) 7 Q% |0 i) Y7 z5 _+ a
deleteAFile = 1 ; \" S0 _( L/ I4 p8 m8 R' s; j6 m
Else 3 T! f) R! s/ v8 m, Q' b
deleteAFile = -1 7 ^4 |/ c+ A% N2 Z/ d
End if
$ y2 q: L, R! s4 U0 i. nEnd Function - h# m) W# @3 j3 c$ [' c
1 i( i/ ~' R% O4 t4 l
'显示文件列表
7 U f r2 n BPublic Function ShowFileList(FolderSpec)
3 C( b/ K% R) s' [9 j3 z8 L, UDim f, f1, fc, s 2 N( H( I! x( |9 I4 u- y, @ }! Q
If ReportFolderStatus(FolderSpec) = 1 Then
+ a8 l+ R4 F7 i( f7 p/ o: sSet f = objFSO.GetFolder(FolderSpec) 1 u' {( f, O$ e$ I. C4 q
Set fc = f.Files . a T0 n3 P6 g6 l
For Each f1 in fc
, J5 n. t# n& E1 \' U+ L1 ps = s & f1.name % }* M3 j1 Y4 f1 G
s = s & "|"
' q' w8 ?/ a5 t. c0 C6 p8 m( w* r9 bNext 2 h# \ F. d& r3 y; {! R
ShowFileList = s & ~; n- x0 \% s5 s$ x
Else ; o& D$ Y" t7 G( N/ [+ v1 J* Q
ShowFileList = -1 . {- F5 ?: B# ?! [, M; {
End if & b! e* W" y' Q
End Function
+ v6 }" v C% H+ X- q O7 p9 `" a5 G: Q ^; i( W
'文件复制 : K" q& H+ Z& f4 H2 z
Public Function CopyAFile(SourceFile, DestinationFile)
% @; A, @) y0 u1 L) ?Dim MyFile ( ]9 e: ^, M- I' f# Z
If ReportFileStatus(SourceFile) = 1 Then
6 M9 c. ~( f: F% D4 CSet MyFile = objFSO.GetFile(SourceFile) 2 n7 K& A: ?$ l9 r& D5 B4 L4 ?
MyFile.Copy (DestinationFile) ! }0 n$ [+ g: a% c& ~4 a& Q
CopyAFile = 1
& ?) q6 e/ p( v( o1 XElse * T: ~/ G6 i. R; N
CopyAFile = -1 * H+ E1 J1 K; x- K
End if 9 @2 L1 [% Z% Y6 ^; {2 K$ w
End Function
7 B* h; i5 f+ d$ R8 U
: y2 N8 ]( B1 |# g+ ], V3 h'文件移动
6 [9 B0 {$ X8 }( T0 y3 `Public Function MoveAFile(SourceFile,DestinationFile)
4 }9 g/ A$ B) h2 l6 I- RIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then ) _, e! v$ _/ L- C# e
objFSO.MoveFile SourceFile,DestinationFileORPath ) P5 ?3 d5 @$ v- F+ k
MoveAFile = 1 ' H' f; r; F- i' [* \3 x
Else : _8 V- L4 }' s# }
MoveAFile = -1 2 [7 [/ u) W' ]' {, o% N
End if ( u3 q# _0 ?0 I& |# F6 l `' T
End Function ) x$ h6 h8 J* ?6 Z4 H
2 s0 k* Z* P/ h& q% |% T
'文件是否存在?
' R' @' k9 y: i( s. k+ n% s+ oPublic Function ReportFileStatus(FileName)
4 \8 S" v- Y9 T2 w1 dDim msg
0 Y, m2 m% {5 ?) W# E' Lmsg = -1
- ~( @9 e' c" h: C& ?2 L( ~4 pIf (objFSO.FileExists(FileName)) Then
+ m* r$ b: [9 @) Z6 q, |msg = 1 4 t4 Q$ m' l2 |/ H, Q3 q
Else " t4 Q' \8 @) O& N: z
msg = -1
' e7 s. z" ?8 E$ T' UEnd If . ~% N3 ^/ D+ \4 @5 B9 U8 [* r% X
ReportFileStatus = msg , b ?0 c1 @* T( n$ ~
End Function . h# s0 K- d: N+ M* L6 O- v
" f- X2 R, f. y3 g3 _'文件创建日期 8 U: _$ v; D( b: u3 a# }( a: ^' r
Public Function ShowDatecreated(FileSpec)
) Q) l! a! b+ N( \6 nDim f
! i# z3 q) b( cIf ReportFileStatus(FileSpec) = 1 Then * b4 h: o% B5 |/ z$ V) u
Set f = objFSO.GetFile(FileSpec)
% A! x) ~4 z% p" rShowDatecreated = f.Datecreated
8 ^) }& B0 Q" z! A8 aElse 8 G. O$ ^) b; {2 ]0 M' M
ShowDatecreated = -1 ; S+ r1 K0 Y0 J& |* \
End if 8 C, y8 t9 k8 b! U' ~
End Function
1 A8 F% i) P" ?$ S
/ V$ l6 k a7 n' U! m: u'文件属性 * q5 w& ]# s7 z4 s0 a. v
Public Function GetAttributes(FileName) 3 n5 x2 T0 p* ~, _* {6 L
Dim f & c9 b& f+ T/ n; Q! B8 |
Dim strFileAttributes
, T) z' s# h4 k# ~If ReportFileStatus(FileName) = 1 Then
3 K; Q( P" E5 n& F- fSet f = objFSO.GetFile(FileName)
6 [% E2 T! y4 Z7 c. M5 Eselect Case f.attributes
& y R+ i% {, {, J' N2 rCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
* A9 A/ ^: X% K# N9 U6 m9 UCase 1 strFileAttributes = "只读文件。可读写。 "
; e2 N0 n' p& k# m- bCase 2 strFileAttributes = "隐藏文件。可读写。 "
" ]! D, W$ e! N9 ^9 lCase 4 strFileAttributes = "系统文件。可读写。 "
) L' \, U0 n+ O) i4 d8 _Case 16 strFileAttributes = "文件夹或目录。只读。 " $ z6 [9 ]% h/ W P0 ^* k4 T
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
& n1 U G6 v" y, V7 a) A7 _& {% iCase 1024 strFileAttributes = "链接或快捷方式。只读。 " % a3 e1 |) P2 N( y, R4 ]- C; s
Case 2048 strFileAttributes = " 压缩文件。只读。"
+ F6 } T8 O0 \+ E/ REnd select
. [# h, w: H9 y- \, E% V. `# dGetAttributes = strFileAttributes
/ E" Q+ _1 h" H. A3 Y2 d6 sElse ( o) J$ F7 y# {: ~* K* v
GetAttributes = -1 . V: h9 [2 y, @8 ^ y
End if
4 k! N/ H, ~# h, j: N( b. G9 ]# HEnd Function
+ U% w+ P3 ?/ t6 c' G* V- Q! }8 f* k& k( k0 r0 I4 b
'最后一次访问/最后一次修改时间
4 N. f5 W" j) _: gPublic Function ShowFileAccessInfo(FileName,InfoType) % C, Z0 j# s8 b
'//功能:显示文件创建时信息
; x( g6 e; Q! k'//形参:文件名,信息类别 4 ]3 j; W9 g7 [$ \1 E+ Y% I; a
'// 1 -----创建时间 2 z+ F' {' k6 m1 h7 D J6 E' B
'// 2 -----上次访问时间
9 H+ _6 Y" o$ r W'// 3 -----上次修改时间 ( W; _1 r" c) n5 p7 K
'// 4 -----文件路径
( J0 U! X: y! f0 N3 ^, P! I'// 5 -----文件名称 ( d! u% i- U: ^& \
'// 6 -----文件类型
& K% W: i; s& F9 S/ X* R'// 7 -----文件大小 9 P% {5 g1 G, ?/ [8 F
'// 8 -----父目录
j, [5 ~+ ]+ h$ r6 A* a'// 9 -----根目录 2 Y6 A h+ P9 c v0 l: v
Dim f, s
# q( z i- p- P9 m3 D$ C( U' e6 tIf ReportFileStatus(FileName) = 1 then
H! j) n0 |# {: ySet f = objFSO.GetFile(FileName) ! v, z' w* N4 e9 s/ _' B
select Case InfoType
0 a; | o% i' m X, J% s8 ECase 1 s = f.Datecreated 0 o5 ]* r% f5 p5 d9 l1 [
Case 2 s = f.DateLastAccessed 6 a, w" Z2 i' m. d
Case 3 s = f.DateLastModified
7 o% h5 _7 N/ q6 f1 nCase 4 s = f.Path
+ x1 M; g: B" U' Z- ~Case 5 s = f.Name 3 k! S1 y5 O$ p
Case 6 s = f.Type
( H7 a' R% k1 z+ \! U8 oCase 7 s = f.Size ; J" W- h& j: I( V: T2 @! F# B# e% _
Case 8 s = f.ParentFolder
% S0 D- _0 C. l# j- t8 l3 dCase 9 s = f.RootFolder / f! R9 ?3 G9 p" D4 M$ W X
End select
" @6 q$ D4 {. g3 wShowFileAccessInfo = s ) e; J( U$ C& k, [' D* V: F' J4 A2 m9 r% ]
ELse
O/ f* {3 V4 V* o; Q* O2 xShowFileAccessInfo = -1
3 S; C5 ~5 `7 F, p3 ]/ A& REnd if
$ X4 E, I N3 F% q% ~( D, b$ K7 _End Function - V. u( w+ J( L
/ i8 _" x; K& B. Y2 ^/ ?1 g'写文本文件
6 D8 Z3 x s8 r$ oPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
) f" K' z" _& _4 a! BConst ForReading = 1, ForWriting = 2 , ForAppending = 8 ) U* z$ ?" L. N4 t- o. Z2 D
Dim f, m
+ P3 p8 U/ f; l. d- h& @! _- Pselect Case WriteORAppendType
8 h K% c, @) q" t1 `2 RCase 1: '文件进行写操作
; s; [# ^$ b/ M: v: @Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
2 [; K$ b, n, bf.Write TextStr ; K' Q% F+ }5 G; L- J# A
f.Close 1 [ ^0 H9 }# k
If ReportFileStatus(FileName) = 1 then
2 }3 X0 v5 B' QWriteTxtFile = 1 : B, p2 ]7 i8 a0 R" ~3 y
Else
( T, k! M- t/ C) kWriteTxtFile = -1 2 P2 ]2 n; }. s
End if ' {) k0 w# c. ?4 m
Case 2: '文件末尾进行写操作 / s% E0 I1 j: M* H2 C4 m1 ~, c% l
If ReportFileStatus(FileName) = 1 then
M3 G, y- U4 p3 gSet f = objFSO.OpenTextFile(FileName, ForAppending)
- L' w$ N$ D9 f" j# af.Write TextStr 4 ?- ~: b0 n& A) c5 }7 \$ _- R
f.Close
" F, @7 I# o [8 O5 ~WriteTxtFile = 1 + a* R- k7 d) L0 L; V& m
Else ) ?! V0 D5 T, ^- ^ h% G2 d _5 b
WriteTxtFile = -1
2 F7 h' W+ Z$ J C7 QEnd if
, u9 U: @# D9 J3 S4 t# ~8 Y kEnd select / e4 |5 A/ E6 u. ^
End Function 7 l8 W/ C' n9 i- W+ X6 x
4 w; C3 X; }, ^, [5 n
'读文本文件 " F$ n. r0 S9 z, k
Public Function ReadTxtFile(FileName)
( F. g& }; [$ \. B. L7 E; \Const ForReading = 1, ForWriting = 2
' B, Y5 I$ T# uDim f, m
8 v$ F- V/ a3 v+ m6 t' ]6 zIf ReportFileStatus(FileName) = 1 then / z2 P1 Z' N8 r0 ], y
Set f = objFSO.OpenTextFile(FileName, ForReading) o3 Z" K8 s, `6 p
m = f.ReadLine ' S0 z2 q, `$ ~( [# [ W R0 @
ReadTxtFile = m ; R: J, \" ]0 i, u) a
f.Close
5 h3 C7 z B+ }! R8 j3 _Else ) L7 o4 z( K4 S
ReadTxtFile = -1
: d( S4 n& Q3 Z1 [- H) W7 g. ]End if $ K0 U( I& h* T
End Function
; `% ~% `) X ]0 z* r F0 `$ S. U1 t6 |! W4 u5 }+ A3 E5 S
'建立文本文件 $ L$ s, L7 Z. H' n* j
) |4 n) L6 R) m ]; r
'=======目录操作======== + F# U9 H; z* b$ L5 J' g
'取目录大小 " m2 d L" E5 g2 t v2 e
Public Function GetFolderSize(FolderName) ( ?4 N! M% g) [7 M/ ~1 B
Dim f . B" m2 s. S2 }
If ReportFolderStatus(FolderName) = 1 Then
4 g7 H; @* b- |# Z3 r7 qSet f = objFSO.GetFolder(FolderName) , k, i0 j+ b3 [' a9 D
GetFolderSize = f.Size
, v' C& ?1 \0 u/ ?3 \% VElse % o+ o/ l) M2 ]8 o5 V% O
GetFolderSize = -1
% ]6 ^/ M! A# oEnd if , _4 z) z5 Q. _% {: G8 v) _: g3 P
End Function
7 R# f8 b% w( O# P4 I: \+ k
/ h# y& X. n/ C) R, a5 }: A( C5 N'创建的文件夹
+ E$ ^0 D$ G9 s! t! {Public Function createFolderDemo(FolderName)
: r/ f! T) E+ R; }8 B3 ?4 tDim f + J" O, l& U( ~0 Q0 x6 }) V, i
If ReportFolderStatus(Folderspec) = 1 Then $ ?, l/ i# b/ B
createFolderDemo = -1 1 f6 E D7 s/ Y- C5 V! v2 m6 Q
Else
9 f+ V6 w7 A/ i% e: x+ HSet f = objFSO.createFolder(FolderName) 4 ]- p+ j' z& O' c) t
createFolderDemo = 1 3 r% P4 A: o2 S4 U
End if
% f9 C3 B& w: I1 `End Function & f/ Q5 k, D4 R6 ^/ N/ D8 C0 ?1 A
! k0 U8 ?2 R1 N4 O
'目录删除 # |; R- b7 e/ F, N) E9 @
Public Function deleteAFolder(Folderspec) : s! D. E8 z5 E) G9 J
Response.write Folderspec
" g' } V* ?- }4 X; G) X* AIf ReportFolderStatus(Folderspec) = 1 Then
# X9 z( f- W# W V2 [( XobjFSO.deleteFolder (Folderspec) 4 n m+ X- P7 r0 H7 D7 \7 j9 ?
deleteAFolder = 1
$ P: n2 h/ n J% Q0 Y n& {; {Else : i7 _8 ^* S+ C
deleteAFolder = -1
7 d! f* k% l8 h! w ~End if . g8 l+ w6 q* T- s
End Function : M/ h9 F2 v/ `2 ^- m3 d
# i5 d" Q: B8 [: ]. [3 e6 F- W'显示目录列表
* K( s# P$ l( T; z5 z3 d+ wPublic Function ShowFolderList(FolderSpec) 0 a6 J0 z1 j, C9 u( F; h3 _: o7 b' p/ Q
Dim f, f1, fc, s
, m: Z" j/ D6 H) p7 v$ w% IIf ReportFolderStatus(FolderSpec) = 1 Then
. Q2 `1 e, a. s0 i- YSet f = objFSO.GetFolder(FolderSpec)
5 ?' k% P" M1 S/ c) JSet fc = f.SubFolders 7 o7 O8 s% h+ N Q% ~4 A
For Each f1 in fc
6 p; j0 |8 n' Q6 b/ t; a9 A8 Ws = s & f1.name
c h3 q4 y6 k+ r$ h3 B7 h& N7 ms = s & "|" 1 x8 {" N ?! a, \. D/ y
Next 8 _/ ~/ x3 x2 a7 X1 J+ o. _3 x; m
ShowFolderList = s
( D7 j. z" d# y- m' Y6 TElse
' j; W0 n2 D _, `, `1 q; B( K/ OShowFolderList = -1
( u: j) G' W9 \+ j: [End if
8 E# M! N' I6 E9 Z( P. u. D# K1 YEnd Function & ]% ]9 G/ L) W
1 K' O$ T& g9 V
'目录复制 1 t5 ~4 t+ z. F; U& h; P$ @
Public Function CopyAFolder(SourceFolder,DestinationFolder) 7 o7 E5 {& A c+ A2 i+ s
objFSO.CopyFolder SourceFolder,DestinationFolder
4 N& Z Q6 F( v3 b' A$ P( ECopyAFolder = 1 7 N2 m( N' y1 m6 p3 V- J/ m
CopyAFolder = -1
" }) {6 z* E2 T8 VEnd Function + R, C6 h$ t3 u, a
; Y# h! J! T ~, n) \ H. ~9 |
! V5 L% j2 D8 z'目录进行移动 z6 q. `* D E7 d( j5 {- ]
Public Function MoveAFolder(SourcePath,DestinationPath) 1 R/ X# o$ ~) A0 T5 U6 H7 k
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then " M+ [* G5 z' ]& O* C8 L! r# A
objFSO.MoveFolder SourcePath, DestinationPath # w' {# k8 R n5 A) Z A8 t
MoveAFolder = 1
5 I9 f$ W2 s& _' U( p) BElse 8 n5 R/ ]% J5 K
MoveAFolder = -1 ) l6 L9 G; ]' I! D+ n3 ]* y
End if 8 u& V2 _) \ F! P0 s# V
End Function 1 r! k# J" O8 ~' V1 Q
* i* Z9 v! ]; s% T8 ~$ E5 { V
'判断目录是否存在 8 ?! I: C5 f5 X! }
Public Function ReportFolderStatus(fldr)
' E- u2 |6 g5 U3 i8 }/ hDim msg
v& W6 r& y; n. }msg = -1
( p3 V$ v% N+ t5 [$ n' ~If (objFSO.FolderExists(fldr)) Then . E+ l E4 |/ y6 a0 u9 {
msg = 1
: }8 |) h7 `4 [Else ; m* g) m9 L4 ~, Z& s1 |( r) s
msg = -1
/ n1 J" e, @, o& gEnd If ! T2 ?0 l' ]' h" O
ReportFolderStatus = msg " c9 M+ T! r6 N
End Function
0 k/ m6 q+ J8 o7 ]) R/ }3 @7 Y. H/ Y- q- _+ U' ]
'目录创建时信息 $ S" x0 e! \# U( n9 R" S% x
Public Function ShowFolderAccessInfo(FolderName,InfoType)
" r9 \: z U' H# D! T5 Y'//功能:显示目录创建时信息 / k/ l4 _! s" _
'//形参:目录名,信息类别 # C, l% M' Z4 N5 _0 Z
'// 1 -----创建时间 5 b. q0 z7 S. V h e7 z1 v( d
'// 2 -----上次访问时间 ; V: S3 L) u# q. s* C# g+ x0 q
'// 3 -----上次修改时间
0 [( r5 t1 O3 I+ B) V'// 4 -----目录路径 + T' ?7 v [) A* Y7 f
'// 5 -----目录名称 9 S4 M' ~" B" U2 w* P7 Q( G
'// 6 -----目录类型
7 b+ R3 K5 v" X7 G( K5 b x& t'// 7 -----目录大小 ; {) u2 E7 z8 b" ], U7 G
'// 8 -----父目录 1 ^. p8 h9 y- u0 [5 v( u- S
'// 9 -----根目录
+ Q7 A m$ | V/ iDim f, s 0 _) M, I+ G1 L4 ~) i& y! G
If ReportFolderStatus(FolderName) = 1 then
! j/ @6 d5 \. h7 CSet f = objFSO.GetFolder(FolderName)
7 B' ^- ?! W: k8 L9 h u) nselect Case InfoType & |; I+ J8 O+ [/ B: ]( n
Case 1 s = f.Datecreated 9 [+ m2 r0 G4 r1 i' s# P7 \' y d
Case 2 s = f.DateLastAccessed
4 c8 ^& `. J# y; P% CCase 3 s = f.DateLastModified R) G$ Q+ P5 g9 k& r
Case 4 s = f.Path / f! L1 R4 ~0 C, Q# z
Case 5 s = f.Name
5 ?6 N8 e0 U8 f# m; X- ?Case 6 s = f.Type : U5 \: |) n% N6 L, p
Case 7 s = f.Size
; G" A0 Q. y, u8 qCase 8 s = f.ParentFolder
' N# z/ O; X" W- E4 MCase 9 s = f.RootFolder
+ P ~+ [4 e3 }, [End select
$ L% w% _5 }% J! O5 z" I6 HShowFolderAccessInfo = s 7 U5 a8 K; `$ Z) I$ h! h7 [, _
ELse
- K# ~# ~( f, F/ J$ r# P3 ~ShowFolderAccessInfo = -1 . l* ^% }# q! L# ~
End if
* k$ C2 o4 z1 w1 U0 l& x) IEnd Function
" `+ f' {. V E* }. S' R% k/ a9 K% X! u" ~' ^/ `8 ~; l3 ?' `
'遍历目录 / O. ?, N4 `7 @3 _ o* c
Public Function DisplayLevelDepth(pathspec) , v* o' D Q0 x
Dim f, n ,Path + x9 c& S! u4 D/ u5 i$ x) R
Set f = objFSO.GetFolder(pathspec)
$ I5 q/ [2 g# ?2 R( a& I9 z3 r gIf f.IsRootFolder Then ; @8 Z6 D r' | r# i( ?8 k
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
$ n) N% g ~6 e" eElse . \* p# H& R3 H0 |% M. |
Do Until f.IsRootFolder # f1 ?; Z0 s5 r |; P( K7 x/ S3 ]
Path = Path & f.Name &"<br>" : t9 y- |3 M l' t
Set f = f.ParentFolder . I5 M* r, i5 h
n = n + 1 ; r' |6 B8 G) D) x3 M! v
Loop
+ H, p1 ?1 a' r, B$ z3 bDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
* Z( r+ r5 |& J5 a8 u: _) V S" LEnd If - j$ q" z) ^0 z
End Function 3 z1 |1 ]/ Q* a& u+ ]- O# H
# h8 i6 D7 o4 x$ N* O" y
'========磁盘操作======== 0 [2 Q8 c2 r# w; f: T6 p
'驱动器是否存在? 2 E2 k6 u$ o& K6 n- x) X4 `
Public Function ReportDriveStatus(drv) ) U& B7 n5 S; L& u8 x
Dim msg
5 X4 G4 @! H# C: u3 G, ?msg = -1 7 u# f# \7 x5 V- ~/ T, \" _1 {$ L
If objFSO.DriveExists(drv) Then 6 i9 \# S9 z: s0 K
msg = 1 ( E- r& @3 s4 F$ P# r
Else
, p$ Y! Q0 ?' F& m, }+ Omsg = -1
% ]; B( U+ H# T0 p- y7 JEnd If ) Z- ~& C2 I* ?4 I; `6 ] W
ReportDriveStatus = msg
3 h6 _7 K& g# KEnd Function 0 j. u5 e' F$ ~# J' }6 e: z) W
( u! L( a2 b# i' p$ K% q
'可用的返回类型包括 FAT、NTFS 和 CDFS。 ! @, b6 v' _0 P1 e+ s- b
Public Function ShowFileSystemType(drvspec) / V1 T1 I5 d1 m3 P0 r+ n* J
Dim d
, c7 L9 S; {9 F( }$ S- e5 f2 D% ^If ReportDriveStatus(drvspec) = 1 Then
/ x' T8 x8 E9 L- J) q, bSet d = objFSO.GetDrive(drvspec)
6 w5 |) \+ v2 Q8 S) _ShowFileSystemType = d.FileSystem 1 g6 h& T$ I$ r- A, a h
ELse 2 H( h" q" P8 I# N" K- I
ShowFileSystemType = -1
0 f) \* q: ?1 P- n9 uEnd if
5 q9 A$ m2 g& L- ?End Function
2 ?9 X: _" d* g1 dEnd Class 6 @& U1 _% m1 F& Y. r8 s; ~
%> |
|