- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6988
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1841
- 精华
- 6
- 积分
- 15416
- 阅读权限
- 200
- UID
- 10
   
- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6988
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1841
- 精华
- 6
- 积分
- 15416
- 阅读权限
- 200
- UID
- 10
|
ASP文件操作大全4 {$ g0 B. D: k2 w- B: v- v( X
<%
: |' p2 V* ]0 E1 QClass Cls_FSO & h) u1 x3 ^$ Z' X
Public objFSO
& y7 |4 d% @ ^0 a) J1 t7 _0 O$ |Private Sub Class_Initialize() & Q' Z3 i% V. U9 [/ H. k+ ~
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
2 S6 j! F" z/ P, X1 N9 @5 oEnd Sub & k6 _$ Y! c/ y! k
Private Sub class_terminate()
6 P: _, ~/ K' H& X" i* [; J3 A# iSet objFSO = Nothing z( V3 ~" _$ `6 a R4 [
End Sub
0 ^ ^9 X3 }2 b4 _
/ l/ G6 ]9 Q$ g! }" B5 E% P'=======文件操作======== ' n9 t" L3 j y8 n: A
'取文件大小
% G4 c9 v) U! I6 N' XPublic Function GetFileSize(FileName)
- P5 j; C! L+ H4 C+ ]Dim f : l. Q% _5 x" d
If ReportFileStatus(FileName) = 1 Then
7 N" e6 b8 z8 ?. dSet f = objFSO.Getfile(FileName)
/ F+ r5 l, |) b3 ]9 {3 }* PGetFileSize = f.Size 9 [ [# \" c% F) n
Else ( |7 `& `& |) h$ _$ `
GetFileSize = -1 8 \! t# S0 r) N. W8 }
End if ! Z: F: f8 T/ t" A; K6 I
End Function ; p4 f6 R S+ D$ }6 `: F( |
7 ]! ]; Z) o/ a1 Y, ~6 R) g'文件删除 , m* ?; Z/ ]; ?
Public Function deleteAFile(FileSpec)
2 K0 o" {* ~' M& j OIf ReportFileStatus(FileSpec) = 1 Then
6 P; p0 E/ u. T6 K- J: |objFSO.deleteFile(FileSpec)
" N8 X- t' S& z9 ~deleteAFile = 1
' i+ k" X/ q' UElse
. m( }. H0 y2 ~7 R7 K+ vdeleteAFile = -1 : C1 |) c7 c7 W8 G Q4 a8 o
End if
: Z2 S0 c+ t6 ?) N2 }# h+ QEnd Function
3 C1 F0 c Y7 V4 k& \: P# g$ Z. x' G, N
'显示文件列表 + B) g: }) O) d2 j
Public Function ShowFileList(FolderSpec)
' l7 {' ?5 i- V: Y6 p2 ?, bDim f, f1, fc, s
0 w1 s q# a+ Y+ F3 _- t/ |2 rIf ReportFolderStatus(FolderSpec) = 1 Then
6 J' i7 v. ~, p5 O n% H5 T$ fSet f = objFSO.GetFolder(FolderSpec) 3 q4 X [$ _* g) W, l1 a) H- _# |8 A
Set fc = f.Files 3 X# g. d4 \, A2 g
For Each f1 in fc . ]+ q6 D$ G: `. |5 R9 i
s = s & f1.name 9 E. t7 g3 Y" h# v2 S
s = s & "|"
- R% z: q' ?1 ]4 X: R6 x' J4 yNext
* h% W$ R0 O+ k M yShowFileList = s 3 R& ~- W( k* {; M9 ~
Else ( |. J# G' W% Q# i- u
ShowFileList = -1 4 l z* f2 m! H. t
End if
* I# Z* O$ B/ c4 g4 J- pEnd Function
$ y; s: I0 `5 r, y. x6 ^ q: b+ Q( c Y5 y2 F% i
'文件复制
; B" h& ?2 {/ yPublic Function CopyAFile(SourceFile, DestinationFile) / c) `. k' |1 s: _; h: z
Dim MyFile
' `, }2 m9 ^+ z: m3 s# J1 @5 i& }If ReportFileStatus(SourceFile) = 1 Then
4 d8 a8 m; _4 ~( N, }7 tSet MyFile = objFSO.GetFile(SourceFile)
. s/ E- X* Q' R5 E4 k% W" y1 |MyFile.Copy (DestinationFile)
2 l4 H$ o/ f* m; ^ W3 DCopyAFile = 1
1 X- t' K5 U x0 P8 @# w, K' vElse / E2 I/ G8 f3 U( v9 Z- z
CopyAFile = -1 ' ~) j; s# X/ S
End if
4 R, v' K+ c: Y& `, a$ qEnd Function $ } W, @; b: O# f' R" T
/ v$ A+ y2 Z/ L) e, h/ m'文件移动 5 Y' t. s0 V: v. y
Public Function MoveAFile(SourceFile,DestinationFile)
- y6 j9 Y% N5 E( Z9 f4 t4 Q h" ]If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
* C, T3 S: f9 RobjFSO.MoveFile SourceFile,DestinationFileORPath
5 X9 {4 J m8 i$ H1 q9 ~MoveAFile = 1 ; Z( b! H) B$ J* l3 f! h, B- E
Else
) a: V& Z; H" jMoveAFile = -1
/ {! E6 W2 u, k& R9 ]2 MEnd if 7 \2 _$ R$ k7 { U6 w/ X: {
End Function 7 z' m4 |/ v! _6 _# S Y2 A
1 J& G. Y# j) A( Z7 K'文件是否存在?
+ G9 s/ j4 i5 ?0 x( j$ v2 E% Q8 ZPublic Function ReportFileStatus(FileName)
( [1 I% r$ U/ J# O, pDim msg
" W5 X, W# E l0 [* ]msg = -1
& a8 e) ^. ?" V* @If (objFSO.FileExists(FileName)) Then 9 ]) x" P' W' F5 }3 {
msg = 1 2 n( i% N! s8 s7 _7 D( J% q# Z
Else
- B% `* z8 ]/ J+ dmsg = -1
7 F3 q) }# z, e" p5 O/ {/ yEnd If $ |$ y) M% j" R. J% }8 |$ X9 X
ReportFileStatus = msg ; v! Q! H) C, Z# j, P
End Function " H: }7 i; K) K3 t
& @( k5 L4 k+ K9 u8 q9 v'文件创建日期
* P# O' R& h+ g% R2 n V+ APublic Function ShowDatecreated(FileSpec)
0 O% k' p* K% }# DDim f
% Q0 b4 {1 [) V' O5 Q& UIf ReportFileStatus(FileSpec) = 1 Then 9 ]7 ]$ b5 O2 L( U) V
Set f = objFSO.GetFile(FileSpec)
4 f2 S4 `2 c4 a( M( O0 K! tShowDatecreated = f.Datecreated
5 w$ b# _) W' |' J2 eElse 7 L' L5 I4 f* n5 ^ G
ShowDatecreated = -1
# K( H2 b+ L) S# D% Z G" Z) WEnd if
9 W, N% ^) z5 vEnd Function : x/ D+ t; c& m4 c' }! O
6 z/ u( q6 {3 d, r. t) H'文件属性 . Z4 l8 I& j0 C5 L
Public Function GetAttributes(FileName) 4 {. ^: V! l; e% z T* F
Dim f
% i2 a5 g- |/ _& [% R, A7 ^7 ADim strFileAttributes
* d" E) ^5 L; ]" Z/ a! y% [If ReportFileStatus(FileName) = 1 Then 7 M2 g. ~2 W6 N" t
Set f = objFSO.GetFile(FileName) 3 A% c, {- N5 F: j2 H+ d" e3 x, j
select Case f.attributes 8 n* L7 D; N* [- e
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
3 ?$ s5 f' z+ H* |( _: `) h) Y8 mCase 1 strFileAttributes = "只读文件。可读写。 "
- o8 u+ }4 U% C! b9 qCase 2 strFileAttributes = "隐藏文件。可读写。 "
8 b0 l: E& ]( R T. c! B6 H0 NCase 4 strFileAttributes = "系统文件。可读写。 " 3 _* P" h d/ T
Case 16 strFileAttributes = "文件夹或目录。只读。 "
5 s5 ]5 ? J rCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " 9 S8 d5 F* `0 |* ]* z; v/ g
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
! y1 h' T( x2 u; ^3 v" {" a5 @Case 2048 strFileAttributes = " 压缩文件。只读。" 9 x. {# \% D: p2 k: u) P
End select 4 m* Q; I9 K- R1 c1 L6 c* x/ C
GetAttributes = strFileAttributes 0 a( o+ |1 `+ {' U
Else
) e9 ~, g" u. t6 o, R: ]4 \' T" M9 {GetAttributes = -1
. U$ t' j' u! oEnd if
4 F( R: C( X5 ~3 b9 ^$ nEnd Function + i: Y7 j; O0 j
! E) R% s$ Z# b1 p) m'最后一次访问/最后一次修改时间
7 j) z/ K- r/ O% pPublic Function ShowFileAccessInfo(FileName,InfoType) $ L( Z, U9 x* P9 t1 k
'//功能:显示文件创建时信息 : f4 c% b1 M8 T6 {
'//形参:文件名,信息类别
* s9 c6 Z9 z0 h) ~'// 1 -----创建时间
; K: {- S1 g7 B/ ~3 k: \ v6 S, n'// 2 -----上次访问时间
$ I7 h8 {3 y6 i# H4 g/ F5 k'// 3 -----上次修改时间 / [ @4 y- h$ F0 i: r# t
'// 4 -----文件路径 - h- R4 E5 Z0 `2 _) i1 N! F
'// 5 -----文件名称
" A: V3 c4 E( \& Q2 a'// 6 -----文件类型
2 c' x7 d/ e }3 J) t# B'// 7 -----文件大小
( \* Q% D4 @+ K: m'// 8 -----父目录 ( r5 i, K) ^" S6 T1 @. y
'// 9 -----根目录 + t; N# c! Q7 o5 t+ |/ t% O
Dim f, s e$ J/ D( X& d5 n8 S
If ReportFileStatus(FileName) = 1 then ! z1 b9 w# \( C: m0 h$ d( q5 m
Set f = objFSO.GetFile(FileName)
! W7 D8 Z; e" Q r# A; U ~select Case InfoType
8 }) h. b0 h9 R; sCase 1 s = f.Datecreated ; |- k' }5 S$ x) }2 ?
Case 2 s = f.DateLastAccessed 8 s( E9 Z5 p' P: G. P. h
Case 3 s = f.DateLastModified
; a% v" ~( l0 J3 u" ]. M. ]Case 4 s = f.Path - l" D2 n6 h0 M9 B! m4 m
Case 5 s = f.Name % p, L8 ^! m8 p1 I. `. L
Case 6 s = f.Type
! w1 Z1 B& F8 [# ~3 }Case 7 s = f.Size |: U1 Q- A6 G& N. @. a
Case 8 s = f.ParentFolder
. m- L+ l. b7 z( P$ [1 j5 Y. W* rCase 9 s = f.RootFolder 4 R! i9 @. E; r6 X" K5 l8 i* c, G
End select ( L3 e! E1 R% \+ {8 y
ShowFileAccessInfo = s : H# `$ i5 T8 @ y& B6 z; u1 u+ J& z
ELse
% _8 ~! k5 ~9 a$ cShowFileAccessInfo = -1
2 b# R3 V: R, {- t7 [* T3 x& e& cEnd if
" a& \5 L0 m! QEnd Function / {0 Z' B4 n) W ^; C: U' Y" r7 q
! w$ j5 F+ d' u: U' {
'写文本文件 s* D2 l7 t/ X% C. S) T, _' d& m
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
- [. |7 M. m* jConst ForReading = 1, ForWriting = 2 , ForAppending = 8 , h8 [# p1 }2 ~
Dim f, m
5 l6 i* z9 u F1 Gselect Case WriteORAppendType
' }' H; d7 S3 l/ K% ~Case 1: '文件进行写操作
& q- F7 s! G- j( K: F) v, lSet f = objFSO.OpenTextFile(FileName, ForWriting, True) 5 u' o! i5 Z& y$ p* d
f.Write TextStr ' S- x4 d- \# ^9 |4 h
f.Close 6 D, { R4 i, I' X h7 t2 s) p
If ReportFileStatus(FileName) = 1 then
7 I2 m) d2 E, k/ |8 `2 u& A8 w: ^9 VWriteTxtFile = 1
3 V+ O6 ?( s* F- VElse U' |+ A/ e8 B. }# L& g# t$ ?
WriteTxtFile = -1
3 }' _8 w8 S' JEnd if ) G! W7 y- C w
Case 2: '文件末尾进行写操作 3 U$ ~1 S6 \6 X$ n$ G7 ?& E; w
If ReportFileStatus(FileName) = 1 then 9 ]6 m- R, r) i! g+ r$ r
Set f = objFSO.OpenTextFile(FileName, ForAppending)
. t" J: {* y2 A8 w/ W2 b2 v; Cf.Write TextStr . E; k- K) Y7 w. W4 |: l
f.Close / @8 ?8 u( H! A% \. x9 ]" M. Y* l
WriteTxtFile = 1 , r$ M+ j9 X, ~ Q+ U
Else % y/ D( _- Q$ W( }. l
WriteTxtFile = -1
) A, b" Z$ f6 B$ h3 Z pEnd if , a. z6 P4 L1 w6 b( t& F2 q
End select ) n* q) O Z$ \
End Function ) B/ v9 n P7 i5 W
# N+ z1 M0 {) h$ @
'读文本文件
# l: k! \0 _. s7 \- m( wPublic Function ReadTxtFile(FileName)
: b5 c4 s) k' |Const ForReading = 1, ForWriting = 2
D9 f! q k+ l) n5 p0 j6 G2 mDim f, m
4 K4 h/ {) M6 P" t, W5 i: XIf ReportFileStatus(FileName) = 1 then
7 b2 }: D9 X! ~* W, {7 @3 LSet f = objFSO.OpenTextFile(FileName, ForReading)
7 M; w' S$ F3 t% d7 z; w" Gm = f.ReadLine ) L, O6 u/ I% _& G
ReadTxtFile = m
$ Q% t! x- B/ Z0 m5 a5 C, Af.Close
# o* o8 _2 q: xElse
/ C5 u6 }3 w4 d8 rReadTxtFile = -1 4 e: [' K* z4 P( q2 T# K2 S5 f; k
End if
2 e2 v5 q+ O# H9 y+ e. G. rEnd Function
! j! w$ c/ p; E4 j; x8 t# O# ?3 u4 m4 E/ {% Y: F9 c
'建立文本文件 % P6 |0 d# {4 l& U! q/ C% f
# I; l+ d/ i, {4 J'=======目录操作======== * T# Y5 B, w, w {
'取目录大小 ! q& E6 X7 r# C+ h, ]. a
Public Function GetFolderSize(FolderName)
3 [5 N1 l2 Z7 N! oDim f + k6 J0 i6 |: [- B8 I0 W
If ReportFolderStatus(FolderName) = 1 Then
5 L) t3 i% K) W" e6 ESet f = objFSO.GetFolder(FolderName) # c; b2 {0 W$ l& n8 A9 Q _- Z: d
GetFolderSize = f.Size
_6 n" w6 B! x/ S! o2 F: T! mElse
9 i0 F2 G7 z0 z/ m( N% d. oGetFolderSize = -1
5 V* M! U; [! l2 O/ CEnd if / t( r6 l% y# H* l, h7 [' V
End Function - i' V6 y( @- n# ^( W: E; B' m* Z
+ @1 i" f! J0 H- j N% v X
'创建的文件夹
/ M1 I# v8 {" k) X2 f' |# P' [. XPublic Function createFolderDemo(FolderName)
! C0 N! t' B6 F: v: U! Z, VDim f
7 S' C5 q- b5 b4 Q5 w6 g) `If ReportFolderStatus(Folderspec) = 1 Then % m8 E' k* P7 |1 }1 S
createFolderDemo = -1
% t; C U1 ?) T# o/ A+ i" YElse
1 z8 R+ X+ E$ NSet f = objFSO.createFolder(FolderName) ) }6 K) O! V# Z7 W7 G1 T
createFolderDemo = 1
# Q6 g! K3 T( Z V) ~, QEnd if
" D, ?( a' X) | i- H+ ^# h) HEnd Function ! G" E; A$ O/ C! R. g
" q1 V7 d T3 \0 }- L8 F'目录删除 8 E$ H6 Q" a E$ q" B/ K3 f+ G
Public Function deleteAFolder(Folderspec) ) X" @4 y {5 C! X1 F: E- T
Response.write Folderspec
3 N! j7 J% p! q7 c# ^! hIf ReportFolderStatus(Folderspec) = 1 Then
. l3 v! K$ a8 y* b8 x/ ^ I) ZobjFSO.deleteFolder (Folderspec)
J$ }$ ^( k2 ?7 JdeleteAFolder = 1 - r6 e6 h% ]3 O/ _) `" x
Else
& t4 G3 E) X/ `" S0 vdeleteAFolder = -1 8 j: V5 E4 |: Q( k& p" O: c8 D
End if
6 T% d. B/ j7 b6 cEnd Function
/ }$ m: f K; q9 b9 \8 N) g. y1 N$ r. u3 k% {1 `
'显示目录列表 7 |' R1 Y8 r2 s4 ~1 X- u7 ]. j. o
Public Function ShowFolderList(FolderSpec) 6 F6 ?$ ~( M" m9 J7 Z2 D
Dim f, f1, fc, s
7 H8 K- B, p4 H+ s1 l- e: qIf ReportFolderStatus(FolderSpec) = 1 Then
+ c" Y1 a2 Q* h, Z& E5 ZSet f = objFSO.GetFolder(FolderSpec) ! @: k, s& \* A; G& }. L9 R* A$ c( r
Set fc = f.SubFolders * R, u" W9 S! c+ x4 m& H
For Each f1 in fc
0 h5 Y& e: N7 gs = s & f1.name / |7 c, e1 n9 x
s = s & "|"
; O" u& `3 |$ L' t& _0 QNext $ a/ Z8 s' N8 I9 m
ShowFolderList = s $ I2 I& ]7 e, x+ W
Else & V9 t1 _2 Y1 F0 ^. g1 z7 m. e/ |9 B
ShowFolderList = -1
& t2 Q* s& O. ^* j* uEnd if 1 d' |7 z$ |( F$ O, n }% \; ^
End Function
* R* m3 p1 J; ^8 o' b; j% o" C$ r
; ~2 j/ | N7 z! X9 |$ k'目录复制
6 U" f, p! U3 b: F- }: _; E! u2 MPublic Function CopyAFolder(SourceFolder,DestinationFolder)
8 M3 F8 n# z9 @3 t: tobjFSO.CopyFolder SourceFolder,DestinationFolder ; K ~4 b% m, r7 j/ ]
CopyAFolder = 1 ; P. ^, W l6 P# k. q3 s/ M3 x8 h
CopyAFolder = -1 & X- ?# c6 \! r* D* ~( v! i
End Function % q0 C X3 }8 E( w4 _
9 A- K0 y& Q" ~
+ [# d' y# ?% q5 |& S6 G1 B _& U'目录进行移动 , V' s9 D* l. }$ a0 P J D
Public Function MoveAFolder(SourcePath,DestinationPath)
6 |; U: S) E0 N' S- R: f* sIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then 9 M) {1 g5 J$ @, U0 S
objFSO.MoveFolder SourcePath, DestinationPath ! Z* C2 ^( O; E9 d5 G; N: i6 M4 M/ D
MoveAFolder = 1
; }9 q4 j/ O2 n- C1 GElse
* D( B- c) t) j- L+ y5 {MoveAFolder = -1
4 {% H/ n# q% l& { k2 rEnd if
7 ^7 K/ Q$ I" V+ O4 ]6 D9 |End Function
: `) W, ^& K# H& @' }$ O
/ J0 w [' l( u$ Z6 _: K# h9 Z; v'判断目录是否存在
, v5 a! w/ Q1 J6 [) {Public Function ReportFolderStatus(fldr) 5 [: K' k, o: L
Dim msg ! V2 ~* s" V/ a' O$ C' T8 O
msg = -1 + \. ~' _; w& U0 t3 D
If (objFSO.FolderExists(fldr)) Then : R( W3 s& s _# B' n8 n
msg = 1 ; d. O$ ^8 A# h |
Else 7 q( ?$ v$ N% `% A) A& G! T
msg = -1 , W# W9 |* [5 G0 d$ T1 m% a) }
End If 8 m( S3 D# e+ g2 U
ReportFolderStatus = msg
, o+ F! A: V, s4 r) R8 gEnd Function 0 ^3 ~: u* e0 A" A
) j4 y+ G5 a# Q4 {2 J3 p; F8 F4 \" ?
'目录创建时信息 9 }5 k: T8 N: c0 k& g: w1 z3 H
Public Function ShowFolderAccessInfo(FolderName,InfoType) 3 C) }1 t! s" f
'//功能:显示目录创建时信息 4 _% l/ ^( @" p
'//形参:目录名,信息类别 6 G; Y& l/ G/ D" U$ g. g8 J
'// 1 -----创建时间
+ K6 U, t. l: @# y/ |$ `'// 2 -----上次访问时间 % ~6 g, q* q3 a1 p5 c3 o( \
'// 3 -----上次修改时间 3 \- F0 l3 j: E
'// 4 -----目录路径 # X7 _# }3 g7 `9 O
'// 5 -----目录名称
; t8 X. T5 N; O- f; D0 E! g) b! }) P'// 6 -----目录类型
. W2 n6 q" w, O9 _! i' ~'// 7 -----目录大小
/ I" U# a8 F! E, S9 m k9 R'// 8 -----父目录
: s8 s0 R( O5 e- Q; o. Q'// 9 -----根目录
7 P/ b6 m. G( B6 l) b, P/ ~9 kDim f, s 4 y, M- T" `* s( ]
If ReportFolderStatus(FolderName) = 1 then 1 ^3 O: k5 w3 K+ I l
Set f = objFSO.GetFolder(FolderName) 0 J+ O& h6 E/ C
select Case InfoType
$ r6 V8 s6 Q+ h. N3 ~Case 1 s = f.Datecreated
$ w! v# v4 W* p: k7 tCase 2 s = f.DateLastAccessed
8 N+ E( h' n. zCase 3 s = f.DateLastModified
0 `1 N, D+ w( l1 L3 A k# C& nCase 4 s = f.Path q- A" Q7 y& @$ t
Case 5 s = f.Name
S3 {, G" ]3 ICase 6 s = f.Type
4 m6 @0 f" B6 rCase 7 s = f.Size
; g+ _& F+ `6 U6 i% f. CCase 8 s = f.ParentFolder
& b& i, v6 z1 J+ [* QCase 9 s = f.RootFolder
: {" A5 N3 p( M4 h3 Y6 \3 M% H- oEnd select
: @2 Q' Q, e1 R9 FShowFolderAccessInfo = s
: p! f/ i+ j- e, l1 ~' pELse
3 e- \$ g# l; }% `1 d6 @+ MShowFolderAccessInfo = -1 # i6 F u; k/ V" B6 k4 `0 }5 f( F
End if
5 Y! H3 n0 r7 dEnd Function
8 U8 e" C% E- T9 p1 }1 k
$ u) g1 K# U* j' E+ C7 l* D'遍历目录 3 u7 M. V2 l; s2 b# D. o
Public Function DisplayLevelDepth(pathspec)
% W+ `; e3 G. D# m9 zDim f, n ,Path
+ z0 E. q b) K- @Set f = objFSO.GetFolder(pathspec) 9 s% ~9 p- h$ Q( Z. o0 l
If f.IsRootFolder Then
% Z1 G0 [, x# P+ e @5 QDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder , o* t( t2 M4 j
Else
; S! s+ Z2 R7 s" z! ?$ z7 t2 c* DDo Until f.IsRootFolder 9 H) z1 e: f+ A' C$ Z0 o
Path = Path & f.Name &"<br>" , M3 s. |# [2 c$ _0 f+ A, O7 i: \! h
Set f = f.ParentFolder
+ h h0 p" d, Gn = n + 1
; K! I' {5 E/ Y. V$ vLoop
( t' j# a2 i% D+ c4 A5 hDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path ! b8 A1 L& k5 \) [3 U/ c% ?
End If
- }# Y) O0 ~& t4 U0 A/ |" REnd Function
* W. A% ~9 X; |$ y% S r
# p1 n+ A7 }/ m: k4 v1 S'========磁盘操作======== : S$ u8 ?8 \' M) G; Y
'驱动器是否存在?
" }# X3 G) B }* PPublic Function ReportDriveStatus(drv) . p9 D- [/ z2 n. K1 |" F: v( x* D
Dim msg
/ E A, o) S+ w2 p6 A* cmsg = -1 ( U, R3 h# j6 N- W5 c
If objFSO.DriveExists(drv) Then 6 [& E' e- y; y* ]& r+ ]
msg = 1 . T; I4 e! f5 a7 E/ i$ R
Else
) ?* b: @4 [, h- {1 Zmsg = -1 - w' p- M+ ^: z
End If 1 D& h) P9 Q7 U3 p/ g7 D% ^
ReportDriveStatus = msg
- Z3 w$ t3 a6 I2 g! yEnd Function
$ |$ `. j4 p7 l$ N6 _0 {+ _* A8 W7 I8 V7 u
'可用的返回类型包括 FAT、NTFS 和 CDFS。
( Z* N4 m8 @9 I1 B+ w6 JPublic Function ShowFileSystemType(drvspec)
0 v5 b% b: T( v- gDim d ) ^+ m& i* [2 ?
If ReportDriveStatus(drvspec) = 1 Then ( G5 ~: K# f8 H' l3 W
Set d = objFSO.GetDrive(drvspec) / ~- `9 A- C4 k% v' [
ShowFileSystemType = d.FileSystem
* \! W. |9 S; o" w$ C. F2 G. YELse
]; k7 C# e" ~, ~ShowFileSystemType = -1
) H) `- a2 M4 j5 Y1 XEnd if 0 g3 C4 z$ d. S* s3 b; v
End Function : N" p3 U' I+ o4 @, \
End Class 9 m" |" h% d5 Y+ {8 T, T
%> |
|