- 威望
- 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文件操作大全
3 S D c( I9 c6 C- C& b$ z<%
( d0 F4 m" \; jClass Cls_FSO " z0 I4 ^& e7 o6 k% e" o
Public objFSO
* \2 E( P( F% x I* c7 k+ tPrivate Sub Class_Initialize()
. t6 Z: b; L3 D* y- kSet objFSO = Server.CreateObject("Scripting.FileSystemObject") e% F; S# P( Z: z
End Sub
! t- ]/ X8 x8 g# A7 j) hPrivate Sub class_terminate()
W, p/ y" i; Q9 T- CSet objFSO = Nothing . b* y2 P1 X, _1 a; x4 Z
End Sub 8 x( t* E5 j4 D3 A4 n# u! j/ y
% J$ _: g! j, c" U9 n& J7 `
'=======文件操作======== ' Q" e7 d/ M$ a# v* Y
'取文件大小 9 _+ v4 ]: c& h1 |8 |2 R0 }0 h8 K" j! d
Public Function GetFileSize(FileName)
0 h6 r& e, x) I! ^6 w: n# @Dim f
, d# s0 l4 s3 |5 L- bIf ReportFileStatus(FileName) = 1 Then + T9 {9 {" L5 O2 L$ _
Set f = objFSO.Getfile(FileName) 0 Q v9 b+ }+ D/ D- z) f6 x
GetFileSize = f.Size
; ^: \) u! O: @Else
2 s4 Y9 T4 [! _. y& QGetFileSize = -1
% J+ w0 {$ H' [2 H6 `+ ?End if , x: S# v; B; f6 |6 ~* H
End Function ) a8 S; ]( W+ d+ o0 y5 c) s
/ U$ H$ J! b% E- t'文件删除 ( R2 \) ^' F4 X9 T3 y; s* U
Public Function deleteAFile(FileSpec) 4 @) D2 q, X, f% {
If ReportFileStatus(FileSpec) = 1 Then 2 a) l) s( E7 X8 A
objFSO.deleteFile(FileSpec)
: J2 b( U5 h, U% c9 `4 ydeleteAFile = 1 5 J2 Q: u2 a5 b, @
Else
9 c/ q' f, C: i$ GdeleteAFile = -1 # h! ~) c' |4 y- C2 W7 u
End if
9 Q& i: z. ^& `# y# \End Function
6 N( W1 _2 E% O5 H
* a- ~1 H, C! E- X; l9 [6 T'显示文件列表 4 v+ T% m1 _* G& v
Public Function ShowFileList(FolderSpec) . ]! X, U0 Z; {2 ^( c5 W& H
Dim f, f1, fc, s 6 o" {5 s" d) |) ]5 q) _ Q
If ReportFolderStatus(FolderSpec) = 1 Then * p# h5 B8 J+ a7 X0 R7 z
Set f = objFSO.GetFolder(FolderSpec)
5 }. E) L1 {1 S2 M( W4 m: Z* ?Set fc = f.Files
9 F s5 p4 T. U3 z# u/ J* a) q. U- rFor Each f1 in fc
8 t) M$ o. z/ js = s & f1.name
# D( {* L6 @9 K- t: @7 |2 {s = s & "|"
; Y; s. Z! @8 k4 \ |( y2 B+ gNext
- ~1 T3 A/ H6 W7 W% TShowFileList = s ' n3 K* v4 Y4 Q% e1 ?
Else
5 d: J4 Z; C$ h; g1 HShowFileList = -1
2 r/ ?+ P9 N# |( J/ ~" n; ^: r' UEnd if
{) p) p6 z: FEnd Function 1 z3 t9 j$ \9 s- g$ @; O
( Y3 D3 W$ n% Q1 `+ Z'文件复制 % S* w0 r" x) |5 l
Public Function CopyAFile(SourceFile, DestinationFile) J5 X' n4 V% U) U; V! H" X
Dim MyFile 8 X9 E$ U2 q* R7 w$ g: i+ _6 p- d
If ReportFileStatus(SourceFile) = 1 Then r! r+ L( H F6 q& z! h$ u- T
Set MyFile = objFSO.GetFile(SourceFile)
) s, W" Z( D- }0 d/ p) @MyFile.Copy (DestinationFile)
1 c# ~& J# f6 H* V8 @CopyAFile = 1 " z; G. c0 W" J( I
Else " h# C4 _3 W9 j. d
CopyAFile = -1
% k. [7 ], K" J% HEnd if N h' N3 j" O7 B3 r! o9 O
End Function
7 }9 ^' O4 C( ?/ W# w1 r8 [) ]1 x. E( ]7 s8 Z5 m# Y
'文件移动 n7 N1 m$ d: g! [6 W1 J
Public Function MoveAFile(SourceFile,DestinationFile) - X' q; J% y& W* D2 [
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then 7 F- w* C9 p! }$ g! m5 f( O' ], |
objFSO.MoveFile SourceFile,DestinationFileORPath
. R; F' `' c% {* g5 [( N9 RMoveAFile = 1
: v' Z; e0 U, LElse
! t7 j' G( h+ u4 W* aMoveAFile = -1 + ?" b; a# V* O' [/ U7 u) h' d
End if
; `1 F4 E; w7 qEnd Function
9 ]6 L# {- U" x& I
1 N4 A) l% c2 Q9 |6 P/ n. S'文件是否存在? ' j% U5 X! K& g5 U" S
Public Function ReportFileStatus(FileName) % z* I5 }2 _" B+ S, K+ S3 X7 u+ X' u
Dim msg
( O. O/ g0 G0 E, Wmsg = -1
) Y) {' [& Y# {0 g/ TIf (objFSO.FileExists(FileName)) Then s* a ^% r) H, p2 O/ P
msg = 1
4 `& _' ] |/ l9 ?Else , J. Q8 U1 B7 t8 p0 k
msg = -1 # x* i7 A3 \# ~
End If
8 N# J9 F2 b& e- V7 \! s) |4 iReportFileStatus = msg ' ~# n: X2 W' x: U" p& c, m8 h
End Function
/ { H8 r; W4 r# H$ _/ y; k" T' b* q' e7 Y2 B' p/ A% E
'文件创建日期
3 n' ~* `9 @0 ^& r( }" pPublic Function ShowDatecreated(FileSpec)
. U) t: b/ r( n; ]: QDim f
O+ ]9 U1 ?( H1 lIf ReportFileStatus(FileSpec) = 1 Then
8 ^- u" i1 s( B" g$ k9 [Set f = objFSO.GetFile(FileSpec) & b1 L; Z" I# Z5 r) s/ [4 q. s; j
ShowDatecreated = f.Datecreated ! x" \$ w# q. i: }# _0 e
Else 8 k) V2 p; P! T9 I- ]% S
ShowDatecreated = -1 ) _" e4 j" t( `; x' ]* L! ]: S; G
End if
2 L, F" ]. E1 _6 ZEnd Function
6 o# P- a9 q$ e# {& t1 Z
1 k: P- ^! U7 `'文件属性
! N- y; f0 H7 e2 {3 a. y: ?3 oPublic Function GetAttributes(FileName) " ^) P. C1 |8 t" C3 K' l7 Y
Dim f
7 W* r8 d. e+ T& ~8 ]Dim strFileAttributes ) F: O5 v2 K) X' x/ m+ v- y
If ReportFileStatus(FileName) = 1 Then
, X& _8 n L4 }% r, D5 VSet f = objFSO.GetFile(FileName) 9 _ G& B! Q. @- P3 g5 G
select Case f.attributes $ `% ^3 o( ? z7 R
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
8 c$ g9 U4 n# x8 l9 r& ~# h9 {Case 1 strFileAttributes = "只读文件。可读写。 " - ~, O5 y% O# b3 X
Case 2 strFileAttributes = "隐藏文件。可读写。 "
) X- J% E7 o0 D- c* n3 XCase 4 strFileAttributes = "系统文件。可读写。 "
* _; @# k) W. `% r9 a# SCase 16 strFileAttributes = "文件夹或目录。只读。 "
' |: ~. B, O7 @) R$ C m5 GCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
. @4 w4 G N3 O x. XCase 1024 strFileAttributes = "链接或快捷方式。只读。 " ! S/ }3 O$ F# l- ^4 p0 k
Case 2048 strFileAttributes = " 压缩文件。只读。" % W Y) Z6 z( k5 O
End select
+ t1 y1 s. L5 U% qGetAttributes = strFileAttributes - `7 L' ?3 Q1 @: {. W* q
Else 2 D9 O$ S, F: z, K6 H2 E6 a" |
GetAttributes = -1
: K, l9 f4 s5 @ B& V xEnd if
- l; B! A: u& g& rEnd Function ) j) ]: C. s0 j7 ?
, [$ {6 n" B4 M5 O2 {% ^
'最后一次访问/最后一次修改时间 " `+ Y* N# m( {$ @& y6 H& n
Public Function ShowFileAccessInfo(FileName,InfoType) 9 V% l( ^) w! y% w% U5 F6 S1 z
'//功能:显示文件创建时信息 ' f0 i- C" ^$ f8 }7 t
'//形参:文件名,信息类别
. L# G. Q4 ` _'// 1 -----创建时间
" |, l. t9 d) [6 p5 N( M'// 2 -----上次访问时间 0 q$ J; U( U0 C- @( c, u
'// 3 -----上次修改时间
Q o( _2 z$ H9 T( {& I U$ U'// 4 -----文件路径
M8 r7 W, G5 X2 `' p# E7 J- {'// 5 -----文件名称 9 y2 R% ?2 \2 G# S7 N
'// 6 -----文件类型 " T6 e& i9 t9 f$ ?: z
'// 7 -----文件大小 , K# o& k5 B" X' `& t4 U, T
'// 8 -----父目录 - G; f5 V; f% U, S$ y2 b. a
'// 9 -----根目录
$ G6 |5 {9 z! W. F; q; t( ODim f, s A, D" I J: x3 K8 @
If ReportFileStatus(FileName) = 1 then
5 R4 I* B5 { f O/ d) I0 KSet f = objFSO.GetFile(FileName)
* X& i8 L5 q8 x7 Oselect Case InfoType
0 u3 `" W: ?' LCase 1 s = f.Datecreated 3 w) o" `( g+ Z% t& }2 p
Case 2 s = f.DateLastAccessed ! ^9 O; O+ A+ p9 {3 b
Case 3 s = f.DateLastModified 3 U P; i1 L* D& L
Case 4 s = f.Path
R" w5 U! @7 r! \% OCase 5 s = f.Name
% Y9 d2 Y5 R7 bCase 6 s = f.Type ; i/ }% T: H1 p% O
Case 7 s = f.Size - f( K1 u- W1 y9 \: ~, N& A
Case 8 s = f.ParentFolder " m, G9 O p" ]9 {0 P* \2 F6 u
Case 9 s = f.RootFolder
" s5 a4 ^0 d- B7 ^! j. t5 xEnd select - |+ E% P4 Z0 y( _5 [# f; q
ShowFileAccessInfo = s
+ ]1 m; R! }' R) `/ g/ aELse
& r$ Y+ o( R. aShowFileAccessInfo = -1 - K3 z1 N& l0 N* M
End if 2 }$ G7 E: |* e& Q( S0 s" E
End Function * h E5 B% p( a
! m2 S R8 E6 w* R. X# D- }$ H'写文本文件 8 y1 y% U! b8 {
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 0 B- H: @) T K
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 # Z U v+ m# b
Dim f, m * ?- z5 J( D) {& E" c
select Case WriteORAppendType 4 r, D1 A0 z" A* s4 m
Case 1: '文件进行写操作 : ?, F' n3 p& L% h& @
Set f = objFSO.OpenTextFile(FileName, ForWriting, True) # J8 Q ]. U: P. ]3 Z
f.Write TextStr 5 @4 Y. a$ ~8 X6 t" r3 h) W& }3 H
f.Close ) X! ~$ O+ N+ a; S% P* i+ F5 {; P4 `
If ReportFileStatus(FileName) = 1 then
1 i+ k T" @$ |' Z i- X8 gWriteTxtFile = 1 h% n v L- K5 Y
Else 5 Y& h8 Q* [+ o- s$ w* b0 I
WriteTxtFile = -1 0 X- Q b) n2 U; H1 _* R
End if 3 `4 d9 {2 t% Z7 \ d& V# s" d
Case 2: '文件末尾进行写操作
4 `4 R6 n1 S3 E `4 A+ A. FIf ReportFileStatus(FileName) = 1 then
3 O N+ x! b2 }9 S, b4 DSet f = objFSO.OpenTextFile(FileName, ForAppending)
/ h9 U) u8 L; wf.Write TextStr
4 `' X0 D: ^- c2 m3 if.Close
: Y9 B. s' E* C0 S7 R2 lWriteTxtFile = 1
9 v- F' T6 N& \* hElse $ k" {4 S" Q/ e% Z" S0 {
WriteTxtFile = -1 0 z( m. l' n1 ]8 T/ G
End if
/ `/ o" A6 Q* L# y6 H( c& t9 PEnd select , u# i, W* C, y9 p t; |
End Function
0 D* _/ a2 r# m# H& G: l5 B) p
7 y# S1 N. |! q% C2 ^- |'读文本文件
N1 K9 [+ O5 [' t; d/ mPublic Function ReadTxtFile(FileName) # C$ g- |/ D( f0 S3 N! x
Const ForReading = 1, ForWriting = 2
5 I6 p+ P1 k& ]' \( [) g; \Dim f, m
3 W: g. u3 r1 Y& @% |If ReportFileStatus(FileName) = 1 then
' ]) J. v1 m3 T% \Set f = objFSO.OpenTextFile(FileName, ForReading) ; a7 [3 A% H4 ]. ~+ {: F' I( `
m = f.ReadLine 6 ~4 Z9 s+ P S2 b+ g
ReadTxtFile = m
" H/ z9 f% F" D$ @) Qf.Close 3 K' q! a3 M. t4 _0 {
Else 5 ]6 z: f3 K8 U) K# w. o) M
ReadTxtFile = -1 : U6 H0 J8 x) c4 w7 Q
End if
8 S2 l, c H a- \/ MEnd Function + ], @+ G: c& S& ~* b5 h
1 W0 |5 b. {& W& G, m4 h8 ?% _+ |
'建立文本文件 $ J/ ?* j# F/ o6 ?' ?
6 V% `2 ~) d: k, {0 {: {' [
'=======目录操作========
5 Z6 Z! y/ W9 x'取目录大小 4 T4 e! L6 J0 Z. G8 A6 W5 ?; y
Public Function GetFolderSize(FolderName) & T1 M$ i3 {8 S9 n- X) `2 t* T+ h
Dim f
, A1 f& C4 z( O! X4 Y3 zIf ReportFolderStatus(FolderName) = 1 Then 1 g, k+ s- M7 H" M1 }. Z, g
Set f = objFSO.GetFolder(FolderName)
* T' v' T/ M, b+ w# w$ y# x1 oGetFolderSize = f.Size
7 A5 V- f) `' S; y0 K% c+ FElse
: W! ~1 Z" h5 C9 c& f/ \GetFolderSize = -1 " Q( i( A# S( m( F4 c; M6 c
End if 9 O( k) V0 ~0 E1 R5 W6 \
End Function
' d$ b* c [ H8 n8 {4 ]+ ~ [; p, P8 ]9 l* z" N
'创建的文件夹 9 I9 a7 D; u- ]7 J: L% n- Q
Public Function createFolderDemo(FolderName) $ U. o/ N- U) D m F
Dim f - ]) I9 t. Z) V) N1 O+ S
If ReportFolderStatus(Folderspec) = 1 Then
" k j" v3 A( R- K |, O. K( a* TcreateFolderDemo = -1 % y5 a: s( Q( a$ {0 X8 Z' c
Else
3 m( ]1 F9 J8 i7 r- n, Z$ a6 a& vSet f = objFSO.createFolder(FolderName)
6 J; a9 n/ W8 B6 n Y: [% N7 ^4 ]createFolderDemo = 1
# `' K7 T: J6 j5 LEnd if
' @$ W8 Q% A' \1 a, }; T$ O& HEnd Function 5 C2 t0 O, B% c5 k7 e
$ [( W/ S( s5 O6 I$ d' M
'目录删除 1 t+ ~/ A( M+ Y/ c+ V
Public Function deleteAFolder(Folderspec)
! n |, A0 P2 u1 mResponse.write Folderspec
3 ]1 d( a6 G, |% WIf ReportFolderStatus(Folderspec) = 1 Then
* }+ m4 V. l/ w4 ^ YobjFSO.deleteFolder (Folderspec)
. [- y/ J0 \; t$ ^7 ]deleteAFolder = 1
* R4 m3 ]( U9 z% `Else
5 s% M+ M" w9 Q: o6 {5 s' F$ jdeleteAFolder = -1
4 l! Y- g) L$ M: T( uEnd if 0 [# k- d) G0 b& x% N2 {
End Function
! O' w* d2 Q5 ]& Z% P7 P6 H9 D
7 j7 e1 U! V) o0 J1 y3 O'显示目录列表
! l$ M$ X9 |) A0 A0 M: `1 h' gPublic Function ShowFolderList(FolderSpec)
# k% u% `1 A) U% P O3 GDim f, f1, fc, s * X: j) x t' b/ Z n- b
If ReportFolderStatus(FolderSpec) = 1 Then 2 X* E2 t& f8 ]' K; i: E2 ?
Set f = objFSO.GetFolder(FolderSpec) . j! s1 L$ b0 r/ @
Set fc = f.SubFolders
3 U6 Q8 \: w# ^4 s) tFor Each f1 in fc
- @! X. Z: u1 |# p9 Bs = s & f1.name ' q( b( a! A4 y+ I0 R! h
s = s & "|" 6 L' j' `* O# S. c7 v) ^" z6 L# v+ `
Next
$ M. u" j0 D ^ShowFolderList = s
8 I" E) T- D" Z# a; L9 HElse 1 [2 G P* r' t3 h& C% v: T
ShowFolderList = -1 - i5 h {& s; J5 W- r, z, \
End if 6 J( ^( T9 ^2 C$ ^
End Function
0 N' m }. _& X4 X3 ^" }3 b5 ]
% ?4 a+ A( _ b% ~. \% B'目录复制
+ r) P5 G& }1 H \+ ~Public Function CopyAFolder(SourceFolder,DestinationFolder) / r4 I# s& l5 F* f9 H( c+ G
objFSO.CopyFolder SourceFolder,DestinationFolder : @" M+ z( b$ l! T7 \
CopyAFolder = 1 ' Y/ L, {3 \7 t% W$ g/ j5 E6 g
CopyAFolder = -1
* O' L7 r+ S+ X) U4 JEnd Function ) X5 t9 ` k, \) Y1 H
/ D0 u( B c2 j& \2 b1 S! S$ J* H ]& d
'目录进行移动
) Z/ l! T8 v5 ~4 CPublic Function MoveAFolder(SourcePath,DestinationPath) }8 I% d U1 t2 K6 o! F
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
5 [6 Q3 k8 V* d% X, }$ ?objFSO.MoveFolder SourcePath, DestinationPath
5 z; n" u8 y3 c* U8 W. TMoveAFolder = 1 5 X; Z l3 I1 e
Else , c. r1 r `2 o) b- s5 s: h
MoveAFolder = -1 + j' h2 m# ?3 A( u
End if
' s% s- H+ S% U$ ^; z9 Q( {% D$ V! XEnd Function
! ^4 J# h+ F+ J& E. o
7 Y; L j1 A* q& i% G& U'判断目录是否存在
. @( {+ i! [3 U8 l% C0 V. RPublic Function ReportFolderStatus(fldr) * i% I0 D( C0 H. w- H
Dim msg , U+ Q. G6 m6 H. `- a
msg = -1 " J& }+ V8 i6 V! R* O0 C8 p
If (objFSO.FolderExists(fldr)) Then
8 Z# V3 T* h: w# z x7 |msg = 1
$ O- M6 A; {# X/ X5 s* g `* RElse
6 `/ F: Y$ p7 a- r) G @msg = -1 ( o2 f6 w! t6 l) D& S0 r; g8 R
End If 5 ~8 r! `) @* `) g
ReportFolderStatus = msg h4 C; j4 i- B$ o' {
End Function ! j" _" V9 X/ s
2 Z' g. J/ C6 H& U4 t- b'目录创建时信息
$ }3 h. X7 D' t; v% n: s# J" kPublic Function ShowFolderAccessInfo(FolderName,InfoType) 7 J" C( O0 H) r5 v9 X& E3 M
'//功能:显示目录创建时信息
1 I3 p. Q7 x0 s# [& t# u8 x5 |, G+ W'//形参:目录名,信息类别 - t; y8 u# r, s7 c- E, s
'// 1 -----创建时间
8 a( U9 v f4 x# Y$ W: @% |4 l'// 2 -----上次访问时间 ; e8 D2 e* A* _9 {( r% m% b/ d% G9 Z
'// 3 -----上次修改时间
9 |! O$ I8 @( N9 b'// 4 -----目录路径
& ^) [4 X# b/ G'// 5 -----目录名称 - Q+ L8 Z5 \, d5 \ ] r
'// 6 -----目录类型
; C# [$ y# _8 V% ^* j1 t'// 7 -----目录大小 : C& }. H% N$ C' _: G# p
'// 8 -----父目录 4 h/ D% ^3 L; Q# y) Z" Q8 ]1 U
'// 9 -----根目录
! k2 S. n1 m6 mDim f, s 7 Y9 n( X$ a1 V% d9 H' o' x+ v0 n
If ReportFolderStatus(FolderName) = 1 then 0 h+ o! S: C; S- I
Set f = objFSO.GetFolder(FolderName)
! o: K+ I, b( J- }4 ]1 U9 K# \select Case InfoType
+ U+ G- U5 d' e5 @/ SCase 1 s = f.Datecreated # N1 N \9 n7 |6 K; h. m; H
Case 2 s = f.DateLastAccessed ( e+ w" O0 F$ @: X
Case 3 s = f.DateLastModified
5 H4 K& n; F% y% @2 r' e5 f2 c# MCase 4 s = f.Path
( y8 O4 l3 f5 C6 \ j/ Y1 w/ ECase 5 s = f.Name
0 N$ r) V# x2 H9 s; v: TCase 6 s = f.Type
4 y5 T; p- H- `! ^9 z: iCase 7 s = f.Size ( S( p' h3 A$ w) o7 O/ L3 M' C* l
Case 8 s = f.ParentFolder
; N: Z% C3 U+ _! L2 kCase 9 s = f.RootFolder / M: m4 u s* b
End select 4 f" f/ F$ M1 ~3 U' U/ @; h
ShowFolderAccessInfo = s z! e4 }6 F8 q$ K6 o0 j% I
ELse 7 U4 Z2 V4 n/ T
ShowFolderAccessInfo = -1 8 }4 ` o) o3 n, N5 W) J6 s
End if
/ k0 }; I" b6 Z% U5 Q% XEnd Function 5 R q5 u/ t# q9 m/ ]" n& T
+ q- b7 f; _8 Z0 s" E s# E
'遍历目录 9 r$ m @' s2 P' b r0 P
Public Function DisplayLevelDepth(pathspec)
/ z9 }, |& c1 hDim f, n ,Path
' v5 q8 f( x# X( g& b; r( C& fSet f = objFSO.GetFolder(pathspec)
: L5 D. v# r6 \7 n4 h1 [If f.IsRootFolder Then
1 L0 u" C; z6 ?( ?3 bDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
7 C* B% [+ p% nElse
1 ]2 R6 H6 E { Y8 }' N6 xDo Until f.IsRootFolder - n) I9 ]" H3 ~+ g6 X: f% X
Path = Path & f.Name &"<br>" , u" S( e6 \4 \, G
Set f = f.ParentFolder 1 _: ]6 `$ I: |- `. g; m
n = n + 1
; G2 ]0 J( t% A' jLoop " T) c, N& P9 v9 H: R1 c# B& u
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
7 S( Q' z$ N, b" F( b) [) B! ?End If 3 d) M* q5 T9 o6 K5 d% K, }8 K# [3 Z
End Function % r# Y, Y# a2 c
% p- f/ J* ]0 m. s b6 H'========磁盘操作========
* L/ P1 d* \3 Q G* X7 m5 T'驱动器是否存在? 5 }) C& y- Q: X6 k; v
Public Function ReportDriveStatus(drv) y. Z/ A& h' O
Dim msg
! B+ Q; b% y; U9 R6 C6 Z. n2 S# umsg = -1
% _/ B& r- e; \# Z0 qIf objFSO.DriveExists(drv) Then
4 |/ L6 y2 `% V; {+ umsg = 1 9 s+ U0 {# U( I2 X* B
Else % P9 A; V" `% Y3 u
msg = -1
1 L* s* @6 e' e, ZEnd If
- H0 H3 B6 i5 A8 h8 w1 g6 BReportDriveStatus = msg
, J" W+ Y i! O% |' a9 H: HEnd Function 9 ~5 F/ Q% S4 _ I2 }
" d/ L- p( ?: z'可用的返回类型包括 FAT、NTFS 和 CDFS。 n2 V8 J' |. c1 b# i
Public Function ShowFileSystemType(drvspec)
! W7 k6 |( m+ J$ Z7 b6 G% i9 U- y- kDim d * i; p: J9 m1 n& {- a+ G/ u- d Q
If ReportDriveStatus(drvspec) = 1 Then
) t9 z- k( @7 i5 kSet d = objFSO.GetDrive(drvspec) : x$ m, K* m5 `$ e$ i( c
ShowFileSystemType = d.FileSystem
+ N9 d. _3 I! \% G& DELse
\ o" `1 {- H. K$ `2 i: UShowFileSystemType = -1
/ z% b9 s: W) _; Z/ a. v) M) ~End if
1 p# a. `8 k7 }End Function
# R h' |6 J* Y& e$ U4 H' y6 _, SEnd Class
c, f7 {0 g4 I# I: D%> |
|