- 威望
- 9151
- 在线时间
- 1303 小时
- 金币
- 7316
- 贡献
- 615
- 存款
- 660001
- 最后登录
- 2026-8-24
- 注册时间
- 2006-5-10
- 帖子
- 1875
- 精华
- 4
- 积分
- 25896
- 阅读权限
- 200
- UID
- 10
   
- 金币
- 7316
- 贡献
- 615
- 威望
- 9151
- 最后登录
- 2026-8-24
- 帖子
- 1875
- 积分
- 25896
- UID
- 10
|
ASP文件操作大全
; ^" z h, q* j/ x<%
* r2 T3 C6 N3 Z, ^Class Cls_FSO
! q$ [0 q7 Y a7 f! w( }Public objFSO & q6 o: q3 {$ ~; H+ k8 A
Private Sub Class_Initialize() 1 G9 } w1 Y; P- O4 t7 [4 P3 \
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 4 s% ~0 I8 m1 L0 N: {
End Sub
+ |* [7 ?5 g, O. C1 c7 NPrivate Sub class_terminate()
8 }. O0 v9 R8 S K5 LSet objFSO = Nothing : f8 f J& S5 B' B- y
End Sub
3 s2 X0 t% S2 m: k+ o& G
) v5 ~# E, H4 w'=======文件操作======== % c* K- _2 W3 ? X
'取文件大小 P& b7 `4 {+ f8 t2 T4 V% n" I/ ^
Public Function GetFileSize(FileName) ; G/ ^6 U0 B- H$ N4 }
Dim f 8 j9 Z# x4 m$ r
If ReportFileStatus(FileName) = 1 Then
! c! k3 L W5 b6 b" l& Y i6 GSet f = objFSO.Getfile(FileName) ( @+ g2 ]6 t7 F- {
GetFileSize = f.Size # f" A4 Y: ]/ o
Else
* H* I3 U; ^& N8 z: ^4 tGetFileSize = -1 1 w+ q h# N, O$ W/ _
End if ) Y3 ^3 u! A+ K8 P. I1 R3 G
End Function
" H9 w# m/ |9 f) v* b6 z) R; p& N4 A& H! B C, d" P: G
'文件删除 * [$ h. ]# i u- i: ] q& _5 W
Public Function deleteAFile(FileSpec)
7 K5 d9 }6 n3 y; z6 WIf ReportFileStatus(FileSpec) = 1 Then % @# n2 |% k' v
objFSO.deleteFile(FileSpec)
0 S& ~, r/ O5 odeleteAFile = 1
# B, m B0 `3 s* Y% W/ N0 u/ G+ v# SElse ' T8 h' ~) W# f3 c
deleteAFile = -1
4 M+ G5 Z; e* w- s( ?End if % y4 u: ~+ g1 j% a0 t) L0 q5 o
End Function
7 E7 K2 g; }1 X, _
: G# |; L$ l! O/ E" J'显示文件列表
3 I E4 e& u8 o% DPublic Function ShowFileList(FolderSpec) * T- O! ?7 P# }8 R0 J! d+ O; H
Dim f, f1, fc, s
3 R5 w" A& w+ ~. V' SIf ReportFolderStatus(FolderSpec) = 1 Then
7 q8 ?6 ~9 u. M7 O! \$ `8 @Set f = objFSO.GetFolder(FolderSpec) 3 v$ s- ^3 t; g, \+ M3 F7 I2 q
Set fc = f.Files 5 m0 v4 w/ ^! b
For Each f1 in fc & W7 N" h9 @4 O$ y6 R8 J. T
s = s & f1.name
- V2 I/ ^0 ~6 m& F) t: K1 ?/ L2 w* ?s = s & "|" ; |) q& _! g/ b
Next $ O, ^# }# t; }
ShowFileList = s 5 e- z- x5 \7 Q: z( t
Else
6 j4 _- s; H9 M+ PShowFileList = -1
. }3 @+ x/ m: F7 J/ \$ R0 X' XEnd if
. O' L% ]' w/ Y. x4 g; E5 S; ZEnd Function f# A& v8 A: t; w! w5 V9 e: h
8 I* a8 ?: N, R2 L
'文件复制
& u0 ~9 `* `+ }" t6 xPublic Function CopyAFile(SourceFile, DestinationFile)
) n2 s }. [# z1 V: ^# `7 lDim MyFile 3 U# s- u1 F$ w" m) ~( N9 D: [4 |
If ReportFileStatus(SourceFile) = 1 Then
' H4 F9 @4 c2 v, j+ TSet MyFile = objFSO.GetFile(SourceFile)
* j* V1 S8 ~: Q$ z. E6 W* N' RMyFile.Copy (DestinationFile)
" t7 g# P, q, R. f+ j1 YCopyAFile = 1 5 ]- v7 p2 R* K. S; v- B
Else , Q) a$ {$ B5 D! o% J J; n' y
CopyAFile = -1
7 L! H) o3 A! t+ j7 jEnd if
9 t U/ N y4 f% w0 XEnd Function p7 `- I; |. x4 l) z: K0 ?
4 Q6 p9 D: s6 g( Q9 f5 z+ D# u
'文件移动
+ e, L9 u8 P% V/ Y3 V! c- xPublic Function MoveAFile(SourceFile,DestinationFile)
X! K. U& X% Y$ ]If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then / X- {9 @; w2 o# M' M; D0 O: `6 H
objFSO.MoveFile SourceFile,DestinationFileORPath
v1 g# _5 Q" |MoveAFile = 1
& d6 O1 C5 K% I1 u; L- h8 `Else
% e* |1 y% C2 R# yMoveAFile = -1
6 m1 t2 Q3 I6 R0 E3 F0 C3 x& ~9 S/ gEnd if 9 D6 x, ^; D4 V; d; {$ _: _
End Function ; S+ F7 N/ _ D- G' H6 Z
# r0 h0 e/ ?0 ?0 R( J, q'文件是否存在?
) W8 W9 U) _$ d4 } Q% K* jPublic Function ReportFileStatus(FileName)
6 P. ~' z, m$ [* ]% GDim msg
2 M7 G5 R* o4 Nmsg = -1
7 }7 Z9 C! N& G2 q$ H8 K6 P+ B4 Y# F1 nIf (objFSO.FileExists(FileName)) Then - f3 F9 [4 ]) S( s3 t
msg = 1
' l3 w; q: V5 U eElse
( M8 v: r& N. `* imsg = -1
; O+ Q/ H! h& W/ T' N5 a( CEnd If & b m1 X! w; |! E( O) s- B% \
ReportFileStatus = msg 4 p2 q7 ?! H* @
End Function # _& r3 b" q6 l c, e9 o
* ?( W$ H1 }) G) Y8 R'文件创建日期 ! X7 Y0 \* `! z7 H
Public Function ShowDatecreated(FileSpec) : f! [2 e( U; X8 z
Dim f " c* d4 q7 w. W8 u# K$ D
If ReportFileStatus(FileSpec) = 1 Then
+ B: ^: R: F2 a8 ]Set f = objFSO.GetFile(FileSpec)
" \0 R4 G$ h' K6 Y4 x/ gShowDatecreated = f.Datecreated
- v' Y$ v- I3 v1 HElse % w3 R$ y" g9 }$ m
ShowDatecreated = -1 & p! g/ ~" |6 o8 q6 L; R
End if - ~9 j! C ^- s2 H
End Function " ^- T. R, D5 r9 A6 z$ P
( g- M2 b% B& H'文件属性
~5 y* d7 `+ O6 l, e( N( VPublic Function GetAttributes(FileName)
; c5 z3 V) e! u1 L6 D* i' N: hDim f
* J! {# n/ M( F( |; w' H6 I( {Dim strFileAttributes r8 @2 [( I3 |2 a$ E+ g
If ReportFileStatus(FileName) = 1 Then
( S! W* |' U4 K6 oSet f = objFSO.GetFile(FileName)
1 Z5 a! M: h1 {% Q/ Jselect Case f.attributes & E( D' c1 a% \' r i+ D+ y
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " ( ~5 [; h* J. F# V; [; p7 i
Case 1 strFileAttributes = "只读文件。可读写。 "
( S7 Y5 z. ~9 F1 q* J( X8 ^" K0 ZCase 2 strFileAttributes = "隐藏文件。可读写。 "
+ k; _1 W) ]5 o M5 NCase 4 strFileAttributes = "系统文件。可读写。 "
: l( U U! O/ H9 U5 u5 `Case 16 strFileAttributes = "文件夹或目录。只读。 "
$ U; c5 D4 V2 K' b0 y% c. bCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " : ]0 [) G+ H( z% H! g
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " 7 a$ |/ ~8 Z" t4 i; ^6 y/ w. H
Case 2048 strFileAttributes = " 压缩文件。只读。" ; U( B" j4 ]+ W+ C2 j+ I3 J
End select
& I/ N% M. f3 J* \4 r2 LGetAttributes = strFileAttributes
1 W! \0 V) l; L: P) x: ~Else % b j2 C3 G/ p6 Y1 b2 n& o
GetAttributes = -1 ) A3 w# E5 `* F) ` e) k
End if
8 F! s9 y* J5 a# J) d3 hEnd Function
, e5 {' S& o6 z( x) f
4 M0 g. [- m. B9 d1 B) H6 r# k'最后一次访问/最后一次修改时间 * L4 E! @1 U9 a' [ y
Public Function ShowFileAccessInfo(FileName,InfoType)
$ ?7 C1 I `2 {, b& n6 B0 w: G/ m'//功能:显示文件创建时信息 + J8 ]. y; M: C5 `9 `9 M
'//形参:文件名,信息类别
9 x; T2 F9 I. \, \'// 1 -----创建时间
2 J9 j5 u, i N. D' z'// 2 -----上次访问时间
/ J( V* i, G6 g'// 3 -----上次修改时间
- j% y$ U& X% m) H' y6 u'// 4 -----文件路径 ! G k" S0 W( C/ h9 k- P
'// 5 -----文件名称
" U: F' L) [9 M6 v6 T& f'// 6 -----文件类型 $ `: G0 ^0 a v2 c! o
'// 7 -----文件大小 9 a& P) G' N, K6 m( m2 V3 V2 C: p# {
'// 8 -----父目录
! b, e5 m9 R, l7 ~" M# ~'// 9 -----根目录 2 ^4 d2 m% X) f
Dim f, s - o- {8 Y& z: j3 Z! I' d$ Q
If ReportFileStatus(FileName) = 1 then
) G/ P) [) V2 n6 U% kSet f = objFSO.GetFile(FileName) 3 s Y1 a5 S+ @6 T* Y5 C
select Case InfoType 4 q8 c$ M7 ^! U0 X& G
Case 1 s = f.Datecreated , I3 F) z4 w4 H& G# W9 E
Case 2 s = f.DateLastAccessed $ r5 {5 F) U) |5 p9 W: x
Case 3 s = f.DateLastModified
# e- {9 r& Y' ZCase 4 s = f.Path 8 d1 r$ m+ u, `7 _6 E2 s% K" r
Case 5 s = f.Name - r) ]7 f6 G" x$ t( A5 @) u
Case 6 s = f.Type % o6 E1 n! I: L% X
Case 7 s = f.Size
5 y* j$ M+ J# i* g' wCase 8 s = f.ParentFolder 3 \7 P; e* \- t
Case 9 s = f.RootFolder
% n1 z E( J7 i- qEnd select
l8 u6 O: {# H" }3 t6 g$ ?7 u! a9 FShowFileAccessInfo = s 1 q0 K. |1 ]! A1 a# r
ELse 7 Z r, F# g; b! E ^8 v
ShowFileAccessInfo = -1
/ _" t# f( ]5 s. E% t* H! w! [# NEnd if
6 P3 }6 e1 M$ U8 Q2 {- J9 O0 g$ DEnd Function
1 }7 o* L% C% h% q3 T8 G" m. q/ T6 }2 |: @0 y5 g& q
'写文本文件
. n! H E3 X( Q) k* ^) |# c5 x* @7 aPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) : j! X8 H% |! [9 P) M& \1 j3 E9 w
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
! e/ c, Q3 h% I7 ^2 fDim f, m
" U4 a9 g3 {6 N d8 J3 ~' B) i0 pselect Case WriteORAppendType
. U6 D$ Y. S: h7 gCase 1: '文件进行写操作
( ~" g- L5 |1 SSet f = objFSO.OpenTextFile(FileName, ForWriting, True) ' @/ l% [# _+ @! H4 b6 d. ?
f.Write TextStr 2 z5 r- k- ?( k: h5 A2 Y
f.Close ! F7 R( ? C. `* R1 e% S: p
If ReportFileStatus(FileName) = 1 then
# M3 o* ^+ l% N2 D) r7 k' r* S) C6 zWriteTxtFile = 1 , N& V- G% b3 G. E @
Else
$ g8 G0 _2 h V/ ^, V2 E$ nWriteTxtFile = -1
4 F- ]) u$ V1 ZEnd if ! O5 J% H* b6 k8 q T- a8 p$ j7 Q' D- ^
Case 2: '文件末尾进行写操作
, z/ C# C7 U* s/ [2 t# M2 eIf ReportFileStatus(FileName) = 1 then
) O% t7 q8 S/ R' T/ pSet f = objFSO.OpenTextFile(FileName, ForAppending)
7 [- x1 t. c8 X7 i" L, pf.Write TextStr ! f, o8 u: M: v# t" X% U/ g
f.Close / @1 R: ^* K4 N6 K; F
WriteTxtFile = 1
: ^. X/ m% U4 D0 eElse 4 ^* } {4 N7 |, ]5 k$ ]
WriteTxtFile = -1 / m) }! ?- j, D3 F) `. N+ T% b2 U
End if 8 M1 s/ `7 @. Z$ {8 h/ V
End select
# D. n/ b% H0 `# v; G9 r, I$ ZEnd Function
* L9 u+ a% X0 |( q9 V
; d. l2 J0 c/ g {6 J @3 y'读文本文件 $ V" R5 X0 d, z. f5 \! y _9 ` s3 x
Public Function ReadTxtFile(FileName) " Y& i5 d' M2 m, \, R6 N# p2 \
Const ForReading = 1, ForWriting = 2
' k u; }. g7 H$ d0 tDim f, m
0 A1 b; Q9 ^. c/ ~" d0 K/ fIf ReportFileStatus(FileName) = 1 then
2 B0 m4 ?' ~ k, d L1 }* OSet f = objFSO.OpenTextFile(FileName, ForReading) . e8 T" V3 Q: D* Y' e9 c* I
m = f.ReadLine 7 U1 t% ?2 o# O# e
ReadTxtFile = m
& W" A6 D* q& D( O2 ?; of.Close 0 K2 j5 Q+ h: m
Else
1 J2 d7 Y j" x4 n. o# [ F- r# Y. YReadTxtFile = -1
' r2 L+ b, M& W& aEnd if
# Q9 Q5 O. X# D( xEnd Function % p! a: K1 W9 S7 d7 Q) s/ V) Z4 W
' L3 ]9 s! c3 X+ w0 ['建立文本文件 8 W' \0 _/ O1 g% J
+ u9 M6 R, g( k3 e* A'=======目录操作========
& s) E& D1 B8 E; A' X# V2 B'取目录大小 7 z- v: N2 N1 S/ m8 e$ ]& o, h% C
Public Function GetFolderSize(FolderName)
! d" _; w5 a3 e8 y) bDim f & R q1 T( ?) ~0 f+ ?
If ReportFolderStatus(FolderName) = 1 Then
5 T3 x: ]. h; L' a! _# l" tSet f = objFSO.GetFolder(FolderName) " w6 A- D) `$ d: z3 h1 q% Y
GetFolderSize = f.Size
1 r' X; V$ j5 a% Y& B; IElse 6 ~2 T$ D: Y# U) v
GetFolderSize = -1 0 |7 A7 J* O& X4 n9 ?% {
End if 5 Z1 f) Y/ Q7 C
End Function * D5 X) b3 G+ [) {. |
2 e% F) X! o2 c* W) |# _( W$ w
'创建的文件夹
# V$ `0 ~: f5 q: H2 LPublic Function createFolderDemo(FolderName) % k& ^& R$ X: R4 L# F1 p
Dim f 9 T) F. b5 A/ i" J
If ReportFolderStatus(Folderspec) = 1 Then $ b: n1 r+ A' X& k1 q* v% U: Z. r
createFolderDemo = -1
Z. |( `" f) C+ E# U* W* a8 vElse % r5 q" M: W' e% v; Y5 ~
Set f = objFSO.createFolder(FolderName)
7 X$ v( G' [, q9 d! z/ F7 acreateFolderDemo = 1
1 M. s$ g2 H; E+ R" nEnd if
* r1 m: e, H. t8 L( H+ ?0 v9 n, sEnd Function
" l. s# b/ W* v& w8 v, } I, D( q, ^
'目录删除
' a2 j: ^! M! b k% [ M+ LPublic Function deleteAFolder(Folderspec)
* S' O' w% k. |3 t1 WResponse.write Folderspec
6 \1 _. f% ?% K$ ^1 L2 V vIf ReportFolderStatus(Folderspec) = 1 Then
/ T1 | z; F9 H% bobjFSO.deleteFolder (Folderspec) 3 a/ y& z; F H8 a2 _7 @
deleteAFolder = 1
2 O( T U3 h- K! ?0 v! V) MElse
6 R. `* `7 A: o* U& s# _deleteAFolder = -1
" x5 a9 s& z5 C, qEnd if * K1 {7 D" P0 r+ i" \
End Function
" O% B' G" H% G; I0 J# k7 M, B4 O
8 K/ W( x% p7 O5 y'显示目录列表
1 a+ H1 f4 o' M- g/ Y( TPublic Function ShowFolderList(FolderSpec) , |% a9 s" g4 B: o8 K" c9 J2 ?
Dim f, f1, fc, s 6 F; J& b W3 j
If ReportFolderStatus(FolderSpec) = 1 Then
8 S6 r. _( Q, \+ d6 wSet f = objFSO.GetFolder(FolderSpec) R) M* D4 a* |3 w. Y3 M
Set fc = f.SubFolders
# F. h0 _- A1 ] ^6 _) MFor Each f1 in fc ) M7 ~6 M7 U- d7 ~. W
s = s & f1.name ' F: o* z1 n" Y, O z# o+ u
s = s & "|" # }) d3 C0 v4 F8 j4 o, b
Next
7 g: @1 v0 G/ ^' GShowFolderList = s n! i8 a$ O; |2 U
Else , c8 V/ Q+ [" q) J6 F5 q
ShowFolderList = -1 ! V: x7 v, N4 v" y5 j% h- O
End if
' G$ Z8 k- u0 i& M. vEnd Function ' [7 Q0 d3 J" ~ R3 i! V
& R( ~: i7 M2 h! X
'目录复制
/ X% }( d% q x0 |+ a4 ?Public Function CopyAFolder(SourceFolder,DestinationFolder)
) O2 f! r, Z4 ~, xobjFSO.CopyFolder SourceFolder,DestinationFolder ; y) \ v0 J6 [* r& ^3 a! Q5 ]
CopyAFolder = 1
3 f3 j+ E k+ U; W- L- T8 UCopyAFolder = -1 ) E. h7 J) |- J8 O3 J. U) Z
End Function
/ c. }- W8 K8 ^. w/ X- D
8 u F P, H; { E$ c% k; q# k- E( F6 Z! P: E& ]# Y5 Y) \
'目录进行移动 , w- C! G- y5 S- S
Public Function MoveAFolder(SourcePath,DestinationPath) & z; m2 f; M& c0 p4 p) D
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
' a2 M; w- {7 l1 CobjFSO.MoveFolder SourcePath, DestinationPath
, |% m# C! g/ t8 D0 }& o8 h, tMoveAFolder = 1
8 y3 y8 }1 O2 U, |5 J3 T' IElse
# U# l9 Y$ r# ?* I8 D% M6 {& ^MoveAFolder = -1 / M7 d% H7 p3 T" Q/ Y
End if 8 L0 F0 G7 d0 y( T5 ~, Q
End Function
! u( a5 O4 ?" u1 w! `
2 R7 d# g Z2 Z7 _! P'判断目录是否存在 ! w' `# B/ C, ]: U8 }
Public Function ReportFolderStatus(fldr) 7 z; F, Z2 F4 q1 c1 t* M3 V- T" o
Dim msg
8 q. e2 @, ^# @3 _msg = -1
4 X' g& n( \) hIf (objFSO.FolderExists(fldr)) Then 2 |' M. b: C6 V2 L, E
msg = 1 + t8 j6 n6 c& Z5 f- c8 Y5 C
Else
. j8 Q% {# l( @8 Z6 Z K& m* imsg = -1 4 {. }0 t( I6 O
End If
/ U9 c5 W$ z' l& X oReportFolderStatus = msg
! t! S) K- T* \) ]End Function
|/ ?9 V; b; R5 m1 I& i
0 B4 \5 B4 E. T" F# C; X9 y* N( k1 E'目录创建时信息
6 o- M8 [' X7 c! \Public Function ShowFolderAccessInfo(FolderName,InfoType) + F3 D& M% \. n2 X% f! d5 C+ \ h7 l+ M
'//功能:显示目录创建时信息
2 {: e) ^4 ~3 c1 G- B2 V'//形参:目录名,信息类别 + W. C: B2 J4 p
'// 1 -----创建时间
# }$ s0 X, h; Y2 _+ A'// 2 -----上次访问时间 1 Z% E: j( |2 D7 ]0 J
'// 3 -----上次修改时间 1 d% q, m2 ~' R
'// 4 -----目录路径 : g1 ]; @/ n( ?% m1 m
'// 5 -----目录名称 0 r+ ]4 t; E3 `1 M5 l
'// 6 -----目录类型
6 F+ w5 q0 N7 l* H'// 7 -----目录大小 9 R8 E, ~9 W o1 t2 v
'// 8 -----父目录 2 ?6 m3 V& t' n/ U% ]
'// 9 -----根目录 , I# e! O9 Z, c6 D" l- s
Dim f, s
; y2 K- ]+ S0 K0 l4 ^! aIf ReportFolderStatus(FolderName) = 1 then " W3 q* Q/ H0 h
Set f = objFSO.GetFolder(FolderName) % `% a/ }6 Q& h* H; G* A
select Case InfoType ! B$ G. E4 M: K* ~* k
Case 1 s = f.Datecreated 6 L) V6 p c% C( T5 j: \
Case 2 s = f.DateLastAccessed
' [7 S! P) s0 X n9 qCase 3 s = f.DateLastModified
+ B* h; D$ W; p1 e! bCase 4 s = f.Path 6 b1 F6 k% {) ^1 G2 I9 A
Case 5 s = f.Name 6 C' g! W6 h4 V. |
Case 6 s = f.Type
' b/ r) \+ U& n2 OCase 7 s = f.Size / M; P1 `( `, ]$ G4 V
Case 8 s = f.ParentFolder
4 V4 ^% g! z' v& j! C1 TCase 9 s = f.RootFolder
3 C4 u: m, u3 T' o8 [: |End select , O/ s+ V$ } b ]9 T# u6 t
ShowFolderAccessInfo = s ' @0 A% M9 X3 X, U# Y
ELse - h4 z1 {0 q2 N
ShowFolderAccessInfo = -1 , A Y8 F6 e# I T. u' U+ y0 t& {
End if $ _ m( I m# D0 Q* E, w3 o8 h
End Function
( b; o& g: T( @& F/ Y; x
3 ?# _* {6 m9 g8 C$ A8 M'遍历目录
5 R0 e& D8 x: k8 lPublic Function DisplayLevelDepth(pathspec) 6 q* U8 Q2 Q0 |8 {( J$ Q1 E
Dim f, n ,Path : Z9 H b$ o1 R' B
Set f = objFSO.GetFolder(pathspec) / `8 L7 ?) N% g
If f.IsRootFolder Then + C- Q) Z9 _4 i0 t9 U2 }' s
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
* J/ ^5 Z5 ~2 u- I$ yElse , O0 U. ^! E/ Y4 L
Do Until f.IsRootFolder
% t$ L1 n# o1 V0 {+ J2 p+ IPath = Path & f.Name &"<br>"
$ w" @/ k. E9 r: E8 s3 W( R7 {* SSet f = f.ParentFolder
( n C V( W3 _! `, vn = n + 1
) c" Q/ _3 K9 |" [& f, e9 c$ E$ ~Loop 8 X2 J& m, ?* s: g' D; }% y6 e
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path / w- q2 Y) O# [1 L1 i1 x7 g8 N
End If
$ P$ x7 m- R* g# {8 \9 x. MEnd Function 4 B4 Z4 z+ H z/ D/ M. M
) _! O$ d. M) x L( ~( ?2 d, p. |) d
'========磁盘操作========
3 M' T3 D* |2 y8 Y) T: @; m8 g'驱动器是否存在? 9 ^. L4 t/ w! e0 v# D" I$ P
Public Function ReportDriveStatus(drv)
7 _5 b: N& z8 @) o+ a; q i9 @Dim msg
- e7 C K* R0 T7 `msg = -1
, j. X1 @+ f- g) h2 ]9 b" ~- YIf objFSO.DriveExists(drv) Then / \* v- g9 ] C) e2 _
msg = 1
; W/ O. d% k; x, n5 b, \Else + h: w. r2 T8 h K+ @
msg = -1
- }' Q: b3 \' uEnd If + ] h) s6 }: w+ R; V
ReportDriveStatus = msg
! }) n \$ }1 W$ T; YEnd Function
4 y+ Y5 r# |/ g
4 V! q* n, U2 j0 `'可用的返回类型包括 FAT、NTFS 和 CDFS。
% I3 B6 R3 k5 v, _+ nPublic Function ShowFileSystemType(drvspec) ; x6 }+ E5 `: @" m
Dim d / b/ R8 E6 N" o- d1 v8 S# A
If ReportDriveStatus(drvspec) = 1 Then
8 P: S" A% |$ i7 b' g" P% N1 dSet d = objFSO.GetDrive(drvspec)
; B: R; U9 G! F& A! l/ X* nShowFileSystemType = d.FileSystem
) {) [# z4 ^/ W* O6 J, GELse
5 m6 k3 k* B9 \9 X H: i q" eShowFileSystemType = -1 ; J3 ?/ A' A6 s2 v2 k$ o0 m
End if
: | B& y# F, r. u$ g6 XEnd Function
/ D, X" S6 Q$ d# N KEnd Class 8 P" V' g# y6 [# {; g
%> |
|