- 威望
- 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文件操作大全
. |/ O/ E! n5 V<% # H, p, m" K3 G4 K7 r
Class Cls_FSO 1 Z; V1 ]7 H6 t
Public objFSO ; ], n5 L0 t' E1 ^' `: c) V+ O
Private Sub Class_Initialize()
( N8 F4 l" I# B1 B& i( hSet objFSO = Server.CreateObject("Scripting.FileSystemObject") , e( h- O8 V: E) |- w8 u; {
End Sub
- l8 d" r' N- J1 y. M R, BPrivate Sub class_terminate() 1 ~* e1 D( |/ R, A' K" z
Set objFSO = Nothing " F% f& u. f/ Z" b U" l! D
End Sub ; g7 H3 I' m/ k2 N+ C
2 h1 w1 {* B2 l! w'=======文件操作======== % X2 D' [+ d! i6 \, k( {
'取文件大小
2 y: B& ]7 m/ L! u* q4 XPublic Function GetFileSize(FileName)
& W: Q5 B$ |" U6 ^: [Dim f
# q& u( k& g# i- |" z# j5 `If ReportFileStatus(FileName) = 1 Then
1 J3 R. g0 g* o% A" e: k ~: K1 w6 GSet f = objFSO.Getfile(FileName) : {. L8 w9 H3 \ x) v
GetFileSize = f.Size . }, o# G" g" h& c- R: A" H/ N
Else
* i6 H; N5 A; l, T5 V( D2 |7 ?GetFileSize = -1
4 {- T& X3 m* p* m( i0 h/ l7 P) i# l. OEnd if
; o; M! u1 m- ]& MEnd Function + I6 z0 _% u7 Q: d% C. d* v3 l9 [
; ^2 \ ?8 L) _7 ~1 v$ a7 q8 [% S
'文件删除 5 I$ Y; ]- C \
Public Function deleteAFile(FileSpec) , p2 p4 y4 |; Q- o5 L$ b) P3 `1 N
If ReportFileStatus(FileSpec) = 1 Then 7 E# }! j4 K% r N# n- H
objFSO.deleteFile(FileSpec)
, S" z# P) C# J) L% q, R% e3 SdeleteAFile = 1 * e, z/ w5 Z% n/ e7 x6 T# l
Else , t& R* t- M+ W0 _& N* i/ o
deleteAFile = -1
' U$ P' X$ `/ i* | Y& aEnd if 3 s% Z( z: x/ T8 z. n+ r+ p
End Function
# H9 p8 E. D( L0 z
1 Z* z f. e, g! _* o" l'显示文件列表
- f; O' x7 }7 T' IPublic Function ShowFileList(FolderSpec)
; ?/ U& c& s# l# p9 GDim f, f1, fc, s % | e1 I% x9 H* u6 Q
If ReportFolderStatus(FolderSpec) = 1 Then ; u) _+ C: c7 Z6 j! J+ C5 ]" ^* w
Set f = objFSO.GetFolder(FolderSpec)
6 ?) R3 n1 J9 X }+ MSet fc = f.Files
( \/ X9 c; J+ |7 rFor Each f1 in fc - J7 v. ^3 `6 V2 k
s = s & f1.name
, ?) k, s. N: T8 k* Rs = s & "|" 7 X% i" [0 t- w; \; k9 z# Y/ L! E
Next 4 K# s, R( `3 @( y' M
ShowFileList = s
# H- ?' X& @' b+ \ k$ h8 EElse 9 S. k0 _( s, a1 ~* a
ShowFileList = -1
( A! H7 }' P! f; ?$ {- Z4 w6 hEnd if % A( G/ ], r: f4 \
End Function % }! q7 g& c0 ^7 ]9 Y# R
* l6 g' B% O; \2 h9 c1 y$ X) I'文件复制
" g0 V$ c8 ?$ A( w' ePublic Function CopyAFile(SourceFile, DestinationFile)
+ O' N1 o5 u- P7 t2 ~5 PDim MyFile ) d& U' D# E& \& D. M
If ReportFileStatus(SourceFile) = 1 Then 8 l0 u( I3 B |3 a% d" u( P1 Y' I
Set MyFile = objFSO.GetFile(SourceFile) : s& d. ?3 j$ f) q; y. x6 f
MyFile.Copy (DestinationFile)
5 O8 q; |% `% d* F2 G1 ]9 n- C, eCopyAFile = 1
* ^( X. ~( o e5 t! P$ t8 S/ `* BElse ) n3 S5 t( v6 S& } C* u! w
CopyAFile = -1
( @1 h5 ~% }/ N: `/ c: ~( zEnd if . `! B5 S* ~" ?0 D# t2 ~
End Function # b5 }! @2 G3 S& N5 w
8 h( d. V7 f B" q2 q2 k6 a' ~'文件移动 + f W+ j) T# g
Public Function MoveAFile(SourceFile,DestinationFile) / b0 x8 _0 F: R) m* t
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then ; y8 J! X/ f5 P1 Y( x5 y
objFSO.MoveFile SourceFile,DestinationFileORPath 2 R+ b' }$ T8 L2 @
MoveAFile = 1
) [6 P) n8 `8 v" S$ J- KElse " I8 X1 l {, {( _6 B& s
MoveAFile = -1 / I" C+ |& o' \. w0 }
End if : I; `& X( T2 R2 D$ w
End Function
3 E$ P! ]1 s4 C
% T' V5 K( S* L( X7 w, @ B'文件是否存在? ! }! ~( A$ g" ?: R7 |
Public Function ReportFileStatus(FileName)
- ^6 x. V0 L' z7 @" d) LDim msg
: X+ {: M1 S, d% p9 v8 Fmsg = -1 ; U. s% @" W( C- w& T8 I
If (objFSO.FileExists(FileName)) Then
/ h* o; W4 F1 a+ `/ @% Y7 vmsg = 1 / @- l; I$ e) `! w5 q% M) }
Else
% I/ N% e U. w) }msg = -1 / L; L% `7 [3 ?/ p& C; {, w
End If $ l; x P6 k7 \4 l/ h1 ]; l2 i
ReportFileStatus = msg + X! {- }7 V$ p4 B$ e: d
End Function 6 a5 [/ B3 i \- W
# N7 p' B4 _2 i8 i* n9 c0 j
'文件创建日期 & |0 F, i- |! S L* j% |4 z6 ]
Public Function ShowDatecreated(FileSpec) ) P6 ^! M" l1 o0 D5 [
Dim f 0 v" W8 }% O' P% Z
If ReportFileStatus(FileSpec) = 1 Then
) K3 j4 b2 s* j3 y1 T' _$ fSet f = objFSO.GetFile(FileSpec)
. |4 F6 t; L7 w1 C; t; h% \6 [5 f2 z2 {" MShowDatecreated = f.Datecreated / L$ S7 T" N- N) i
Else 1 b7 |& Z& q% A- H m
ShowDatecreated = -1 ' j) e1 d( Q/ ?. w
End if 4 @$ z4 h2 o# I/ L$ W
End Function ( H) X& {& U/ L2 {' G4 w
/ L) b: |( ]- y
'文件属性 9 H! e1 D0 b3 t5 x* Y W4 B) @
Public Function GetAttributes(FileName) + _$ H( g' d" f6 n `
Dim f
( m& h9 Z' \8 W1 a/ xDim strFileAttributes ( b% W% c0 G7 S
If ReportFileStatus(FileName) = 1 Then ' f ^* K! C( c
Set f = objFSO.GetFile(FileName)
9 D0 z9 B' P8 Q8 ^( w1 Aselect Case f.attributes
- U. r" b% g' p+ `1 Y+ H/ N3 u5 ~Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " : X- ]" y. I9 O( V" U# d
Case 1 strFileAttributes = "只读文件。可读写。 " 8 x9 h B. P* m
Case 2 strFileAttributes = "隐藏文件。可读写。 " . q6 {( G V9 W7 f; u+ o% l. ^
Case 4 strFileAttributes = "系统文件。可读写。 "
9 h. w* W% K: S1 TCase 16 strFileAttributes = "文件夹或目录。只读。 "
9 i8 b- r: F& Q+ S! NCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " ' X& J1 \1 m8 x7 _0 I' e
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
/ ?1 ] a" j( L' ]0 A7 }+ h% ~% cCase 2048 strFileAttributes = " 压缩文件。只读。" $ _( r( @! j6 @1 c
End select
: h2 P. ]7 M" Y; m( Q9 dGetAttributes = strFileAttributes 1 j/ `) K$ d3 O% F/ {
Else
6 I1 [& F1 `5 K; JGetAttributes = -1
4 }; f, f3 `# dEnd if
5 `4 H$ d) n6 T$ N" g1 l" {5 cEnd Function
; L5 } a" p4 g9 T# u+ F! t, U7 a, m9 j: |1 B
'最后一次访问/最后一次修改时间 6 t( C' \) I8 @( a) t' F4 t+ {1 ~
Public Function ShowFileAccessInfo(FileName,InfoType) ' v3 Y* |+ ]& x! p# A) y( V& i2 _
'//功能:显示文件创建时信息
) n0 _% R6 d4 i3 s4 [8 E9 ~7 s'//形参:文件名,信息类别
8 C9 p3 L+ ?5 G/ Z+ _) l0 ['// 1 -----创建时间 6 Y( C& _$ s$ _0 t: m+ Q! b
'// 2 -----上次访问时间
t2 G9 P0 ^$ Y2 O2 v* V ?. ] w'// 3 -----上次修改时间
! C4 Q) |% N5 K' x+ h y'// 4 -----文件路径
5 U% j9 z8 Z" j! R'// 5 -----文件名称
5 I+ L1 x% _% ]8 y* P7 c'// 6 -----文件类型 Y- W* h5 L/ [& o* i
'// 7 -----文件大小
7 o1 s* A! s7 J2 i6 p) Q6 g'// 8 -----父目录 # ?2 S h% r7 [3 }4 v
'// 9 -----根目录 ( J; T, r" a, n$ |
Dim f, s
0 m6 Z6 h' o; p2 j8 K: PIf ReportFileStatus(FileName) = 1 then
8 B0 s3 K- x% l/ R+ D% M( ISet f = objFSO.GetFile(FileName) + p# `; m& V; V' B, R
select Case InfoType
& Z9 h! a' W% e( \9 S1 B! \Case 1 s = f.Datecreated
; I1 l4 k7 L7 wCase 2 s = f.DateLastAccessed
8 C- N. L! n3 j" _, V2 l) HCase 3 s = f.DateLastModified ' Q' `4 L$ ` c$ s
Case 4 s = f.Path 8 B# Q$ \1 f8 L
Case 5 s = f.Name
% S7 m( g1 P$ n7 g' C7 S, g% _Case 6 s = f.Type
: d- u0 Q$ {" [3 C& e1 S8 LCase 7 s = f.Size 0 x6 ^ B3 |3 w
Case 8 s = f.ParentFolder 4 g# S- S! \" M5 N3 r0 }
Case 9 s = f.RootFolder
$ `! ]" M+ v- }End select ' G( D' a, I1 J! D. k6 R2 J
ShowFileAccessInfo = s ' n! y/ R) U+ i1 L( U
ELse
3 W" D( W; o+ n: C3 k& v5 Q# ]5 [ShowFileAccessInfo = -1 % _3 q, [( C, ^/ C- M! z2 ^
End if # i& r# b# o& m3 c3 I2 B4 l5 q
End Function
/ b4 |) z5 C& z& s9 N* `' }" u% r( K! \3 O+ O) P
'写文本文件 / q- w* z' `6 V$ k& `8 M
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 6 P( N G, V u! p# j
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 2 m+ [( H; S& s4 _. i2 ?
Dim f, m , J5 I9 l" U& j5 \3 j
select Case WriteORAppendType
* c7 n1 g& t( r6 [! l3 ?3 n! Q1 eCase 1: '文件进行写操作
+ s* Y$ F5 ?9 x' m) W& Q9 {Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
9 d" U2 N& D3 ?5 w4 V1 H% Gf.Write TextStr
* o3 \$ j" o; n( C$ lf.Close 1 Z% j( e; i/ F, i3 a0 f2 A
If ReportFileStatus(FileName) = 1 then
! ~; U/ D( R+ j* ]5 tWriteTxtFile = 1
7 z- x, Y8 m& s# ~Else # q, d$ K4 ?' K4 W
WriteTxtFile = -1
" ]2 q6 d M% O7 M* s7 R; \End if , `! g4 _" C- E$ y; V
Case 2: '文件末尾进行写操作 . W% l/ ~& \6 M1 {5 V9 A' }
If ReportFileStatus(FileName) = 1 then
% p I* j! i8 _, M4 u3 E8 J5 q/ SSet f = objFSO.OpenTextFile(FileName, ForAppending)
% A; t2 d; B3 I: Ff.Write TextStr 4 h9 P( O/ r! N% p$ I
f.Close / z5 w6 d% J8 Y* ?! R
WriteTxtFile = 1
0 p# M2 W+ ^$ b) b# z0 c: F/ S2 M h$ GElse
5 q/ e/ x2 H" F4 F M! R) r# wWriteTxtFile = -1 ! Y5 T6 `$ W& s# O
End if
% Y6 V5 K4 y# }6 {6 s7 UEnd select , m' }# i* P T6 _
End Function " l L9 ~) N4 k6 }1 p/ N2 [
) w2 `2 y! C5 g+ A2 T9 `
'读文本文件 ( J2 ~( u* `& Y
Public Function ReadTxtFile(FileName)
, J' R7 Q4 U* B) P- h" |2 EConst ForReading = 1, ForWriting = 2 6 o3 Z3 l: `" D/ [& k w+ s
Dim f, m
8 E9 @3 t( f( E6 cIf ReportFileStatus(FileName) = 1 then : F0 k4 v0 Y2 P8 \+ Y; T
Set f = objFSO.OpenTextFile(FileName, ForReading) 4 v( ?8 g3 j* w. r. h+ ?! E
m = f.ReadLine ) s! \7 A# s% i9 ~% v- a
ReadTxtFile = m
% p1 d" R/ p- [+ u: r X7 `f.Close
7 {& T/ E5 G& ]; f, AElse
9 R# |8 K b. a8 C) ^ReadTxtFile = -1
0 K. L s/ @& J9 Y9 PEnd if * ~0 Z& h, F) D7 R2 g# i0 K
End Function % h7 X1 e3 ^1 o. K
1 O8 H1 w0 S! c+ ~3 M# w/ {' ?9 I/ x'建立文本文件
- L+ z$ \$ b8 @* |; n% I6 d0 @4 k( c/ ^
) o0 w9 ]0 _6 K& a/ B'=======目录操作========
& }2 N) f L! e; ^" w) a'取目录大小
. q5 Z& k: N R% }Public Function GetFolderSize(FolderName) ; d+ X2 ^1 {, X6 r7 c9 D
Dim f 6 s) c# e+ G! H+ V3 N) A
If ReportFolderStatus(FolderName) = 1 Then + g0 C2 k7 s3 u5 U# ~
Set f = objFSO.GetFolder(FolderName) ) I4 g- m- g* ^' i4 f2 k
GetFolderSize = f.Size # n7 J$ u4 {: j9 j7 k' ^' x1 M
Else z' G9 v2 _, G6 j4 R# {! R3 C1 t
GetFolderSize = -1
# g, b* z* k8 pEnd if / E. p' |' o- U5 {
End Function
. G3 a G8 V/ h& J
& C5 |7 z. \" ~'创建的文件夹 . B, w- }6 b7 h2 n) M3 {' ]
Public Function createFolderDemo(FolderName) & R; b3 D6 @6 M* Y/ `6 _( J
Dim f 4 x& w/ j% c+ J' @% Q
If ReportFolderStatus(Folderspec) = 1 Then
+ W1 y$ k' p- hcreateFolderDemo = -1 / b* Y; ^ W6 T6 {4 K$ C( r
Else
& z6 v4 S+ W& h: S5 W2 }Set f = objFSO.createFolder(FolderName) 4 R1 H V! A/ S; w J
createFolderDemo = 1 ' `/ Q2 S8 {- T6 S* I
End if
$ r5 V2 K( Y' }( K; ~% q% SEnd Function # {6 Z$ p2 v# F# ^% L- j/ E' e
1 n, L0 t9 x' [' s" f9 M4 e! c3 c
'目录删除 9 V" b( e- Z+ Q( i0 W1 Q
Public Function deleteAFolder(Folderspec) # L& Z; M) n5 ^% M. N
Response.write Folderspec 1 E& D: }5 q( f
If ReportFolderStatus(Folderspec) = 1 Then
+ t3 R0 k; Z' z- n9 J; _# X" S) a9 P5 KobjFSO.deleteFolder (Folderspec)
# ~: l9 G# A! S8 ]deleteAFolder = 1
8 A) V( k: H0 bElse 2 d: ~" y! d4 N& ~% K8 a. f$ y
deleteAFolder = -1
# E0 z4 W9 d; K; L# u, wEnd if
, ?" ~% {. Q9 P2 ^7 XEnd Function + U6 `, F2 h3 N4 A
. r3 F; b- x! r; E3 X. ^, u'显示目录列表
* e, x, ^' C! H1 f5 oPublic Function ShowFolderList(FolderSpec) ) L, h( O7 _. e8 |0 }
Dim f, f1, fc, s 1 n: A1 {" o X- M' J
If ReportFolderStatus(FolderSpec) = 1 Then ! T; A" Y* b* i, Z2 l9 ^( d% h
Set f = objFSO.GetFolder(FolderSpec)
2 x) c% q: M! h! ?Set fc = f.SubFolders
3 j7 z$ |/ z# m# `& tFor Each f1 in fc / ^ n) i* N% z# s- G& j4 J
s = s & f1.name ) e- S1 q: M' M2 X& s6 j: q
s = s & "|" 6 B& b7 d. l1 w1 ^3 r
Next
$ c; Q- L* {2 l2 j5 G+ VShowFolderList = s " V4 ^3 s3 I; W5 }% R
Else 2 z- D# J& K# D3 A2 |7 j4 U3 {9 w
ShowFolderList = -1
" o7 r6 C( _: UEnd if
: O" h, u% F. M( E# e. LEnd Function & v# t5 \2 r' a! J8 c2 G1 ^
2 }$ }( W" c0 d/ R$ j4 d
'目录复制
2 E" `& o% |: r; {- APublic Function CopyAFolder(SourceFolder,DestinationFolder)
* }4 U# T! l. A0 ^. B4 mobjFSO.CopyFolder SourceFolder,DestinationFolder
4 N f4 K W2 `6 a. \CopyAFolder = 1
) W; L6 A/ _) X5 |! Q$ ^CopyAFolder = -1
+ F9 U3 B8 ?! Y' b s- O9 qEnd Function
2 d7 D' ^: r: n+ `9 y5 ?: _: I3 f: v4 ^, M. L, d
8 B. x6 i' `0 ?) \4 ~'目录进行移动 4 {9 ?1 s' X4 h0 ]1 g) k* L
Public Function MoveAFolder(SourcePath,DestinationPath)
, n* Y1 `/ J$ s+ p7 A. dIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then , |- }* Z f( Y0 X3 G
objFSO.MoveFolder SourcePath, DestinationPath . w# j; \& r# K3 C) t, |/ o
MoveAFolder = 1
4 W1 F# u. Y/ i2 G0 YElse
4 g5 c3 J; S. ?5 O0 k2 WMoveAFolder = -1
" r; O0 e( u0 C8 bEnd if $ }) f3 u( Q- N- |# F5 u
End Function ) V- l; @- j7 h& Q5 d0 N
K. @3 n2 X) L! n( H) J; [/ b4 @'判断目录是否存在
* |4 Z0 t# W. ]2 t3 B1 XPublic Function ReportFolderStatus(fldr)
, w1 S) b/ l' H l& c6 g8 CDim msg
. M- ^! Y, x) G3 Bmsg = -1
2 T- r/ m/ k' P! I" xIf (objFSO.FolderExists(fldr)) Then % ~+ z: e% Q; [, ]! Z) g7 B
msg = 1
7 f! }& [4 O1 A0 }% ]4 nElse
" i3 t% y7 e/ y8 y3 V' ^8 ]" E% V2 Bmsg = -1 - S" R% T# T1 W' v2 N
End If 5 R7 p" a S! z4 d8 a1 p
ReportFolderStatus = msg
, y. ~8 M/ _, B* tEnd Function E3 P( h, R' C7 v0 j4 y. z
& J X6 O4 l% L( \4 M% Y6 l
'目录创建时信息
) f; L( s! w( r J4 v* N' pPublic Function ShowFolderAccessInfo(FolderName,InfoType) Y+ }7 |! t6 c
'//功能:显示目录创建时信息 1 N. w5 y9 P. d- {6 D9 P, K
'//形参:目录名,信息类别 5 o# H4 ], s$ ~0 w- h) i
'// 1 -----创建时间
& v" s) \# N+ ]$ L3 `: N5 |'// 2 -----上次访问时间 4 A4 W4 W" x7 M3 b+ v9 X
'// 3 -----上次修改时间
( M5 S0 \/ G' c# F) O'// 4 -----目录路径 ~' G4 A) d3 A0 `' V
'// 5 -----目录名称 % Q, ]. i( [ T: Y. d
'// 6 -----目录类型 : Y+ X; s+ h- F9 D
'// 7 -----目录大小
/ C- _! |2 i' L. k1 o% T'// 8 -----父目录
+ q9 X2 o% d N4 ?$ B4 I'// 9 -----根目录
6 e+ k) p; J$ i# ZDim f, s
( M+ _4 _: m! F% ^0 kIf ReportFolderStatus(FolderName) = 1 then 2 T' G. p/ s$ \0 }
Set f = objFSO.GetFolder(FolderName) 2 L* k: S6 c9 k' ^# U$ I
select Case InfoType , n, i% @6 C& ^
Case 1 s = f.Datecreated
/ T$ K1 C8 g6 o: F& h; [Case 2 s = f.DateLastAccessed
8 K% j- a& Y$ X( f. l+ @Case 3 s = f.DateLastModified 8 ?$ R8 w/ a4 i' c3 M# F; J
Case 4 s = f.Path & l/ R/ w9 D* ^
Case 5 s = f.Name ) A' b/ s7 u" X& G$ Y j6 R
Case 6 s = f.Type V2 K& O9 W& n! H9 x1 ]
Case 7 s = f.Size
' ?! K/ N5 y c k2 `Case 8 s = f.ParentFolder
) D6 N! s# n, S: b$ {) ^; qCase 9 s = f.RootFolder / O/ ^, g" @( @0 p0 ~" h. Q
End select
+ g9 r+ O `& O5 b, WShowFolderAccessInfo = s
/ o) L* b! m! P' K8 C" c4 \5 PELse
# s# {8 `7 D# g, ^" t( vShowFolderAccessInfo = -1 % p; p% n& K0 x; ^9 w
End if
6 \7 S" Z" z4 {7 e" r) r7 ~End Function
8 m1 ?( R0 h: W# M$ j! N M
( X9 h. `0 b' u'遍历目录
E6 K$ @- {1 d s$ C% tPublic Function DisplayLevelDepth(pathspec)
, [7 Q( u' A9 O, Z6 W" }' GDim f, n ,Path # o3 I/ ^3 n s v' f9 B: k# B& I
Set f = objFSO.GetFolder(pathspec)
# I% {' X9 D5 K7 A# ?$ M* z; W rIf f.IsRootFolder Then 8 e+ I! b- P: b3 j
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder ! C( a$ p0 F" r, D! g! [1 K
Else
/ n7 c0 ^ \, b4 a- {+ i* hDo Until f.IsRootFolder : y, m4 b$ T4 \" w9 p+ w2 u4 b
Path = Path & f.Name &"<br>" , u. }0 H* x5 v" O* V
Set f = f.ParentFolder ' a$ g$ T3 o% @2 `0 \4 j7 i) y
n = n + 1
6 s6 P+ h3 t, o* U; K9 N( G9 b5 iLoop ' z; L$ e+ J. o. J# A
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
2 d* \0 r% @- N& \( p) ZEnd If : ^9 M) v, W x1 f
End Function ! ?+ d$ r6 ~* Q% _3 s( U: O! I
& S( a& l1 S' W8 g9 L'========磁盘操作======== $ F u+ z: c5 S. a8 j( S
'驱动器是否存在? ' k( e: w0 o' N! V% w I B+ O
Public Function ReportDriveStatus(drv) $ A; g" h% ~( e- M6 ?% l
Dim msg 0 a2 t$ U4 l: G
msg = -1
8 ^- V; U& D0 l8 \If objFSO.DriveExists(drv) Then & q4 ^5 [9 g. S$ E
msg = 1 * t% @; r: l7 a3 {8 W
Else
$ m7 J3 P6 e6 ]7 z! p: S Lmsg = -1
. n+ a& x6 w/ l- T! K# ?End If
/ S( u j. z! m2 y3 a* l2 k- oReportDriveStatus = msg
; V- w! o* W3 R {' T6 tEnd Function 2 G8 Y/ [5 O+ X3 U# i' O% e
: a: F. f& }# p" k/ J1 L'可用的返回类型包括 FAT、NTFS 和 CDFS。
0 \/ n: y: c' l$ J$ ]& j& V4 \( {Public Function ShowFileSystemType(drvspec)
, y7 l& P, c s8 @0 g0 G$ WDim d ( c0 R* T9 p3 T
If ReportDriveStatus(drvspec) = 1 Then , G }$ M8 k# y% v
Set d = objFSO.GetDrive(drvspec)
0 a# O8 a3 a0 ]7 B5 eShowFileSystemType = d.FileSystem 6 s( ]1 K, c" L; Z
ELse ' e) z" p8 N7 \) h0 P' |4 S9 g
ShowFileSystemType = -1
. U" n w D2 y$ D& V/ oEnd if
! y0 a! W( u7 Q, Z" Q- ^ p# _& KEnd Function
7 o1 H" ]$ U5 o% E8 xEnd Class
# {- Z3 H& ]/ z2 Z. C%> |
|