- 威望
- 9151
- 在线时间
- 1303 小时
- 金币
- 7319
- 贡献
- 615
- 存款
- 660001
- 最后登录
- 2026-10-4
- 注册时间
- 2006-5-10
- 帖子
- 1876
- 精华
- 4
- 积分
- 25897
- 阅读权限
- 200
- UID
- 10
   
- 金币
- 7319
- 贡献
- 615
- 威望
- 9151
- 最后登录
- 2026-10-4
- 帖子
- 1876
- 积分
- 25897
- UID
- 10
|
ASP文件操作大全- m3 N- s c5 m2 C# n) W; l8 ~0 o0 g
<% 6 X- \' h" }$ x/ _( V/ _4 C/ q; Y
Class Cls_FSO . ?( M- h: f! y) a6 e
Public objFSO 4 `0 r z2 Y, }1 u& p; n
Private Sub Class_Initialize() 4 @+ N5 |: w# d* j0 ]7 H0 ]
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") , D( I5 w$ c+ s# Q
End Sub 3 V. q k- {. N" B3 `5 q0 t# Q1 z
Private Sub class_terminate()
7 m3 E, ]+ J' C4 F4 Z cSet objFSO = Nothing
# e/ {1 s8 g( B& V6 X, h4 v; h- PEnd Sub . l* A0 ^6 s& g1 W9 J Y
, P- Y! w' A$ W5 L1 i5 M2 Y! c7 M'=======文件操作======== , K3 T3 P8 T9 X( Y% _& m
'取文件大小
4 P: X" s7 H5 |% I9 h! LPublic Function GetFileSize(FileName)
5 T- t" e! z7 c8 u' I8 yDim f
; X# E0 C: [4 x+ ^( q+ LIf ReportFileStatus(FileName) = 1 Then 3 V' a1 H3 B( g5 O
Set f = objFSO.Getfile(FileName)
4 i& J, P/ ?# r6 [GetFileSize = f.Size l, V; S3 e- }5 O5 N, |
Else / h& z% m# j/ D4 x3 E
GetFileSize = -1
3 y8 s; M2 h: O" y; G0 X4 S- `# AEnd if ; t& h- k2 s5 m0 C2 M
End Function
$ x+ V/ Z, q& @! |7 S. a3 m# _. B9 S+ y- v; _* T$ M) X& [
'文件删除
3 u6 c; s2 Q: I- B1 M+ z- F/ @/ @* UPublic Function deleteAFile(FileSpec) 0 g- \, A1 v" N% P5 \/ _/ ^
If ReportFileStatus(FileSpec) = 1 Then
2 r2 r' ^, s2 i& U5 fobjFSO.deleteFile(FileSpec)
% \3 x5 u( P6 k0 {9 G! o* vdeleteAFile = 1 9 ^9 r$ w( A: ^* p" |; E Y
Else
' V9 ^$ ^3 L) \5 e' n6 EdeleteAFile = -1 8 S) |" K# q* Q: v9 F/ L) ~
End if
) |9 u' v; i# w! x* AEnd Function B5 V i) D0 J
. F/ g: a0 G7 H* s$ x
'显示文件列表 * G4 l$ L' E% g0 x4 \4 @2 E0 G
Public Function ShowFileList(FolderSpec) & E* Z4 u, X L+ z. h
Dim f, f1, fc, s - ] ], [% J, M' {3 w
If ReportFolderStatus(FolderSpec) = 1 Then
% B$ O' ^7 n) [% M3 e. ^Set f = objFSO.GetFolder(FolderSpec)
: x7 E2 R" n& J% p7 `9 N' [Set fc = f.Files
0 `7 q9 O1 r2 c% i; jFor Each f1 in fc 8 v0 u: k. y6 A
s = s & f1.name 0 J" D2 t3 |5 @# ]# x$ j8 e
s = s & "|"
& N) Z& D- e1 Y. b+ mNext
' ]9 P, k4 {1 [2 pShowFileList = s
( b; I+ Q) Z1 y q" O$ MElse 8 D! p6 Y. t t0 ]$ e4 ^4 p" k
ShowFileList = -1
' }0 R' V# |- IEnd if
' r3 J! X# L0 ]/ L4 `( Z& FEnd Function , Q* a) p$ S( Q5 h
. V2 C! |$ a9 l$ E3 ~! L
'文件复制 ) C$ U/ O6 H1 m
Public Function CopyAFile(SourceFile, DestinationFile) 4 t# s+ B# R! A/ j' b
Dim MyFile & ^. f: g7 c/ C, L9 v( k8 m1 @
If ReportFileStatus(SourceFile) = 1 Then
$ a6 q/ f- u' F7 u4 O' GSet MyFile = objFSO.GetFile(SourceFile) $ R6 ] F# m6 c' k& V
MyFile.Copy (DestinationFile) : ^0 M3 B: U: f6 q; ~; K
CopyAFile = 1
, | y% ]9 N' q' R" XElse ' o0 K% j$ a" B! k( h+ ^
CopyAFile = -1
% g$ t- z7 l( V" r7 |End if & j1 ~$ h c$ i; ]( I; `9 m
End Function
( A( }5 w2 d* N. i9 _- ~! j: ~. u7 g8 r
'文件移动
& ^! I5 P a! o. `5 aPublic Function MoveAFile(SourceFile,DestinationFile) * {# H4 B1 f1 Z& v" {0 {
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then " D! e* `4 L- e, {, J
objFSO.MoveFile SourceFile,DestinationFileORPath 9 \6 k+ e2 H$ H K i
MoveAFile = 1
: [- b8 K) i- B1 X: D5 q4 MElse 6 T: j' u$ @5 w6 n+ N0 M7 ? e
MoveAFile = -1 ; C$ q8 L6 D# N
End if . v2 b1 u# H, E2 n, K- U# S
End Function 8 w; ^% @: N& E7 G. K, s4 _
; d5 O: Z1 V/ V* k5 p
'文件是否存在?
2 y/ x8 v( v# c' w6 v& c6 lPublic Function ReportFileStatus(FileName)
9 K$ b' g: O+ b4 oDim msg ' h" h7 b8 m3 l- ?
msg = -1 % a+ ]1 T9 n8 ~3 a
If (objFSO.FileExists(FileName)) Then
8 A; q3 d, h- I/ X+ F: u6 Smsg = 1
8 D- C. r1 e F, yElse * r: t' V: f3 ]" O
msg = -1 ! z. [5 y& d) H# u* J7 M; M7 D9 k
End If
E/ X5 h" k4 u. JReportFileStatus = msg
# s$ ^" B" H0 M& o! aEnd Function
: @$ M1 w, D* d9 A6 F) m
1 t9 M% F4 a3 ^- j/ p( ?'文件创建日期 . h5 n6 b0 z8 ?! L
Public Function ShowDatecreated(FileSpec) . A9 P F, s1 }( O/ F/ e% ]
Dim f ' \! A0 s7 E! R) @3 Z! o
If ReportFileStatus(FileSpec) = 1 Then
" f2 P( T- c* Y0 p5 H# ?Set f = objFSO.GetFile(FileSpec) & {5 c9 _2 k$ G" T2 g
ShowDatecreated = f.Datecreated
9 H8 N" U5 f% B( ~( wElse
% `- A% n1 \0 o6 pShowDatecreated = -1
& v1 C$ B ]1 R, b) K6 AEnd if
9 B8 w5 v/ {3 p# E) |/ ?. R/ \End Function 4 c; W. Q# @- r! A, ]* |
+ O- q) Z; B/ Q' P: D5 O
'文件属性
- o' ]7 K) a0 H$ W: g/ ^) \4 nPublic Function GetAttributes(FileName)
% o C" `9 r' H, `, FDim f 5 D; }/ c$ d2 s8 X: B4 J$ d% }/ b" c$ u9 L
Dim strFileAttributes ; ]6 Z5 @" Q8 a/ X- w3 P5 O+ r
If ReportFileStatus(FileName) = 1 Then
- E/ }1 |- c% oSet f = objFSO.GetFile(FileName)
- M! T" l% m9 Q& {* gselect Case f.attributes
% a' O, [1 ~1 e, k) `2 ]Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " % o& d: W+ q: Z* ~% I+ u$ s
Case 1 strFileAttributes = "只读文件。可读写。 " 9 s& P5 v4 ]1 L% k5 e
Case 2 strFileAttributes = "隐藏文件。可读写。 " - \& J' G$ S7 ^% ~# w" o) X7 u
Case 4 strFileAttributes = "系统文件。可读写。 "
7 }9 j4 y, q2 r$ s: w* g0 K6 jCase 16 strFileAttributes = "文件夹或目录。只读。 " + W, U8 f! Y8 b7 X+ k$ O" [
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
# ]8 A; _* q; r: BCase 1024 strFileAttributes = "链接或快捷方式。只读。 " 7 |! H. A' Y" _4 b7 ~. P
Case 2048 strFileAttributes = " 压缩文件。只读。"
b) N6 ~3 w& L- m' N- e zEnd select # k# o! j( }0 ^; i
GetAttributes = strFileAttributes ) y/ K6 z% v% b; V0 z0 N( u6 r) x( w
Else ! T$ ^# ]# S1 i! L& z
GetAttributes = -1
& W O# _5 k1 h8 w/ L+ g+ e" DEnd if # C* p' P; c! |: S8 J
End Function
. o) Y8 [: e. t- m
( k7 v+ L: ?8 Q+ g* i'最后一次访问/最后一次修改时间 * ^( a* j3 K* O5 q4 x7 d O! ^
Public Function ShowFileAccessInfo(FileName,InfoType) ; X. O7 G+ E/ l/ N3 J3 J4 l2 L
'//功能:显示文件创建时信息
2 @" O4 L9 d. O& M'//形参:文件名,信息类别 ; {8 Y9 W) i: H! x( m: L4 w# n
'// 1 -----创建时间
" ^0 w1 T5 A3 T% S* `( d9 ^'// 2 -----上次访问时间
7 z) @* E5 V' }/ w2 k'// 3 -----上次修改时间
6 [) v! _) H% O& Q4 j* t: _! ]# j'// 4 -----文件路径
; o! H. C5 x/ ?, B2 _'// 5 -----文件名称 6 t. R, G. h1 s W
'// 6 -----文件类型 3 q& T" O$ R2 [$ {
'// 7 -----文件大小 D3 R7 Q0 W$ L
'// 8 -----父目录 2 ?. y# L6 e$ a$ \3 E3 V o
'// 9 -----根目录
8 [) l& M4 n' F& Y- @' HDim f, s ; y# i+ A: I) }; c o
If ReportFileStatus(FileName) = 1 then 8 F: S. g% U' Q' I
Set f = objFSO.GetFile(FileName)
# R5 x5 F7 z* U- m2 p4 Hselect Case InfoType $ M4 u0 X R K5 G3 e
Case 1 s = f.Datecreated
& V3 [% V8 P% J( X) sCase 2 s = f.DateLastAccessed ( @) D/ r+ p6 [" d
Case 3 s = f.DateLastModified
' w7 Z! {4 [% M+ GCase 4 s = f.Path
& c: c2 E+ u* `0 NCase 5 s = f.Name
; o/ s6 F: D/ ]# h" WCase 6 s = f.Type
2 p$ ?! x+ z; T( E9 J" |Case 7 s = f.Size ) z( e$ ~, S% ` G
Case 8 s = f.ParentFolder
' `6 c1 L$ F7 g3 s7 |Case 9 s = f.RootFolder 4 q$ D) R3 p+ v0 @' g
End select 0 j9 V; Y& z4 \7 L E2 Q+ F
ShowFileAccessInfo = s 5 h. n1 l5 N: r
ELse
' n' f6 V# C+ t& `5 X. v* b0 ^ShowFileAccessInfo = -1 * r+ F# ]) j2 u8 |( E4 C
End if
3 R# [, q" K9 X yEnd Function . a8 ?: z# e% v+ S; e
# ^# z4 u4 F3 F* \) @
'写文本文件
0 l; |/ M2 v4 {2 R; m0 |& XPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) T! K- M2 ~9 C8 R6 G1 H
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
) F) K h8 Y4 Y$ ]$ `Dim f, m
4 [& C6 g6 p4 `. |- Iselect Case WriteORAppendType
$ h; T) |3 c3 N& A! U# j; aCase 1: '文件进行写操作
: b& a8 v" T: Z2 OSet f = objFSO.OpenTextFile(FileName, ForWriting, True)
) C# H. ]! R) l3 n4 o- W& }) Rf.Write TextStr ) A' q: J U' t+ D, w$ i
f.Close 1 Z* m+ n4 V5 A7 R- X
If ReportFileStatus(FileName) = 1 then ( w, |1 }" @) d2 j
WriteTxtFile = 1
1 g* N' N. S- }: @0 OElse , H) q5 p B: i; V! R0 Y% a
WriteTxtFile = -1 ( r# {/ u) W6 B2 q$ w# T
End if 2 I1 H, l- d6 q5 p0 U1 D6 r$ j
Case 2: '文件末尾进行写操作
, r6 G- Z' d' oIf ReportFileStatus(FileName) = 1 then
" p& u' {( v. D. L- SSet f = objFSO.OpenTextFile(FileName, ForAppending)
, y# X1 z. X! ~& T# U2 s1 Gf.Write TextStr
8 I1 G6 \4 V* R; Af.Close F$ s6 e" z9 S6 u e# O6 M
WriteTxtFile = 1
+ W( i8 k7 t1 |3 @2 ]4 ]Else & m" m* d; q/ r5 E! |3 g* y: k4 I
WriteTxtFile = -1
V0 o) K( f' nEnd if L% }0 }5 L9 A9 V6 c, h! Y
End select $ Y$ S$ [4 f9 m! K6 {) n; }5 m
End Function
- c. d* v; R; g# z0 F5 r5 X
# i3 j) ^! j6 n'读文本文件
9 X5 D* a8 s) TPublic Function ReadTxtFile(FileName)
) M* T' q) I: ? x- P& u& L7 Z' GConst ForReading = 1, ForWriting = 2
5 ^' T2 a2 G, I# YDim f, m / w5 i7 `3 M# V/ |9 ? w2 V
If ReportFileStatus(FileName) = 1 then
# D/ s6 b% o5 A% J* q2 d# g9 [9 lSet f = objFSO.OpenTextFile(FileName, ForReading)
9 J7 K* h# t6 ?m = f.ReadLine 6 N; ?" t8 h3 |! X/ R \
ReadTxtFile = m " M. [& Z( v% i4 E
f.Close
9 d; e1 G) R1 O( t) Z$ S$ J) s2 t5 VElse $ B, J0 h' |1 U" @ R3 R- `
ReadTxtFile = -1 O" e# p6 V1 v+ I
End if
X& }: G( O/ N7 y1 `0 XEnd Function
1 `8 v" ~& D" b' q( R
) w" }* a# R6 t! ?5 D. f5 R/ E'建立文本文件 % m g& m( H! u8 ^; {" O
, q8 `8 y$ c. Z7 S; K
'=======目录操作========
6 Y2 |, U7 ~& C) f. R'取目录大小 9 p5 V/ }' G) Q K. O W! o `
Public Function GetFolderSize(FolderName)
. ^7 y; t4 U1 a$ R1 S$ rDim f . v+ u& U7 v; P- V* l: B* E
If ReportFolderStatus(FolderName) = 1 Then ( t) H6 e( v! W3 d
Set f = objFSO.GetFolder(FolderName)
( y9 }, d. L. }: ?6 j' V) [/ K/ HGetFolderSize = f.Size
' q/ b! ]6 o$ T, S( [Else $ E/ u, S) w8 {+ y0 t/ i' D
GetFolderSize = -1
7 c7 c. x# r- Z; S) ^( zEnd if
3 N5 ?5 q/ \8 {$ PEnd Function / M* P& n E' ]' t
9 j4 ?' c2 B9 C! G9 M'创建的文件夹 0 } C" y+ _9 |6 K# c
Public Function createFolderDemo(FolderName) / g1 c* ]8 y% \5 O) O
Dim f
5 Z" x6 G- h! a8 [3 ?If ReportFolderStatus(Folderspec) = 1 Then
$ n4 M9 }5 Z% gcreateFolderDemo = -1 Q. M6 W4 K" n
Else 5 r5 ~. `6 L3 J! P6 r8 R
Set f = objFSO.createFolder(FolderName) : `" F4 U& G5 |1 O/ M0 `2 _2 y1 q. W
createFolderDemo = 1
- F2 i' ~/ X/ e" DEnd if
. d. j* N- L1 E9 z, F1 gEnd Function
) L5 p) U5 ]0 T% l% K" G* x
0 n2 ?8 @ j# ~0 G3 ?' K'目录删除 2 Y. E4 w1 ?% b. q# |4 c2 t, v
Public Function deleteAFolder(Folderspec) ; o1 ^0 D% }$ Z8 r5 _2 N5 Z
Response.write Folderspec
* A$ W( g7 h7 r3 n8 P4 @- nIf ReportFolderStatus(Folderspec) = 1 Then G9 G a: U$ x& d t
objFSO.deleteFolder (Folderspec) ) A: _- p! B9 F7 @: ~2 T6 g' Q6 [3 a
deleteAFolder = 1
- ^9 q; b3 M9 rElse
- K( _4 F9 h0 VdeleteAFolder = -1 " Q3 e3 {& q+ x3 v" Y/ S4 C
End if 0 i. D1 e& V$ N1 E# k" ~0 e
End Function `, _4 |/ x4 E# _- m1 d3 G, Y) c9 ?
4 }2 S4 _! J3 V0 x/ N7 [* t'显示目录列表
( t; U7 j0 M" f* \" ~7 `' UPublic Function ShowFolderList(FolderSpec)
5 F. j1 A0 c+ i# B( I6 mDim f, f1, fc, s ! t# _2 K9 e% q5 S A" h3 i
If ReportFolderStatus(FolderSpec) = 1 Then
! C8 U: ~) N4 t$ ^& HSet f = objFSO.GetFolder(FolderSpec)
/ `) R) T. G3 F/ rSet fc = f.SubFolders
; A6 m0 B4 b8 Z3 m# p$ zFor Each f1 in fc
) y! E0 Y9 X7 S% ys = s & f1.name
/ u# R& p8 f% t4 n! @s = s & "|"
+ e* H; C9 S) J. k2 ]3 Q2 j0 F/ r( ENext 1 t7 ^( O2 u0 A% q: J3 |) B7 L$ G
ShowFolderList = s ! h1 }$ Z2 x/ O2 _0 ~" X0 L
Else " }" f4 s3 I/ }" q/ H7 E+ _
ShowFolderList = -1 ! X7 w7 l) V$ J8 N) E* \+ V% m
End if : Y2 Z* Z: J" A) ]8 C
End Function
8 z- p, Q/ t: u5 y
) P' h+ S( Y! j; L'目录复制 A' |0 G5 |- M$ S7 |5 T4 {4 i6 f5 H
Public Function CopyAFolder(SourceFolder,DestinationFolder) 0 L) ?. k" v- p9 I9 _, H F
objFSO.CopyFolder SourceFolder,DestinationFolder 6 [5 j8 P) G) d' W5 R
CopyAFolder = 1
5 F: K# `1 V* r0 v aCopyAFolder = -1
e" o# _5 c7 ^: V, P. DEnd Function 3 B4 X+ H p, }' o; E
" w, f, B# M; i5 V3 }
2 v" [3 T# W, V" `0 m# E8 [* v
'目录进行移动
# O; b* Y! p3 g& qPublic Function MoveAFolder(SourcePath,DestinationPath) ! O2 ]- {1 _2 j4 | `
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then 6 M. s* }; L7 j& A) U
objFSO.MoveFolder SourcePath, DestinationPath 0 V( `0 ~. m0 r, D r: l3 X3 U
MoveAFolder = 1 & h" G( N( }3 k" t4 d; W0 R
Else
# \7 b: Y; ]+ t* V# ^MoveAFolder = -1 # G/ ~. W! X7 D) S! @! O& z
End if
. R: d2 i0 Y; b5 YEnd Function : M5 Y4 q" J3 K2 B6 O( G# J
1 O1 |$ T1 ~5 p
'判断目录是否存在
& v1 P' g2 C! ~" l' X3 J9 _Public Function ReportFolderStatus(fldr)
# k2 }4 J. d# H# ]* vDim msg ! J2 t6 g$ K- A$ p- t2 X1 p
msg = -1
, m! j) U% f/ W8 n! x% XIf (objFSO.FolderExists(fldr)) Then
+ V" H6 y. ]4 B6 B0 mmsg = 1
( w2 W! C- x$ sElse
, z& }( x) t: x4 i b7 W, R! P( cmsg = -1 $ E2 ^; g A9 O$ ]/ x( B9 a
End If
, N! S5 q! q! y! M3 ]ReportFolderStatus = msg
) L; L" U& D. E. |6 C. O! H4 W9 F$ \5 BEnd Function
* d/ M' R% O' q0 _5 E; T2 |1 C- r$ B) B3 C& b# ^& U
'目录创建时信息 4 Q* O5 T) N- g5 w- u1 w" W
Public Function ShowFolderAccessInfo(FolderName,InfoType)
& C/ v6 V) J* `8 _'//功能:显示目录创建时信息 d1 N* n! a8 l0 F0 i
'//形参:目录名,信息类别 ; Z. J3 J0 U# e/ J
'// 1 -----创建时间
2 M& s( t! l5 K% A'// 2 -----上次访问时间 3 S# n2 @5 \, p; m& _8 x; g: q
'// 3 -----上次修改时间 $ T/ ]1 D- r( b! {& @9 \
'// 4 -----目录路径
/ p1 j+ |$ s2 ^& _, s$ U'// 5 -----目录名称
# Z- }% v3 k8 J }) |- h; L' W'// 6 -----目录类型
* F* `2 w' ], u6 w'// 7 -----目录大小 : H2 B1 I) r6 w: c9 v
'// 8 -----父目录 & |* Z' B# S( o9 s; c" s- E
'// 9 -----根目录 % _% s1 J4 v1 S- B1 X1 f
Dim f, s - u) {* ^; k' _. @* X
If ReportFolderStatus(FolderName) = 1 then
( X! Z1 _* t' ]! OSet f = objFSO.GetFolder(FolderName) # y% _! d* a3 W1 G. O [7 e! q
select Case InfoType 1 S8 m0 I. T! N, H! v7 Y; C
Case 1 s = f.Datecreated / }+ s, D) R5 ?
Case 2 s = f.DateLastAccessed 3 w! r' c' [ r- N8 a: e* {' ~
Case 3 s = f.DateLastModified 9 z3 O* B- C1 C6 W, X; v
Case 4 s = f.Path & t: \; b9 ] A' C
Case 5 s = f.Name
* ^5 W0 f; e1 X8 ^) i5 K% I- mCase 6 s = f.Type
3 N) }8 q7 I7 W) s3 zCase 7 s = f.Size 0 e! h. c* s& |0 V5 `% ?' h
Case 8 s = f.ParentFolder % `$ V" ?# o0 }3 v
Case 9 s = f.RootFolder
& I$ t7 k- w! o* t# m$ eEnd select
1 P. X( ^: U! n. e }9 PShowFolderAccessInfo = s + J' ~, i' U9 \# V
ELse
. Q6 L+ v) x: q- J: EShowFolderAccessInfo = -1 : b: z2 g0 Q* j: K8 ]
End if / w5 Z5 b) u- D2 U' b$ B: Y
End Function
( V) q! g8 N4 Z0 r
: m1 a4 v5 c5 ?'遍历目录
/ i# v/ A: }8 S5 Q/ f) ^2 tPublic Function DisplayLevelDepth(pathspec)
% R1 {, r. e1 L/ L3 @Dim f, n ,Path 4 t3 A3 G: l% o- `" H- J
Set f = objFSO.GetFolder(pathspec) 4 n+ K m; K1 R
If f.IsRootFolder Then T- T" |! i" R2 c: \& x
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder & j$ X) `$ }0 W3 d C% P+ g
Else
7 _4 v+ x9 a$ f8 K" P, Z" c1 aDo Until f.IsRootFolder
* f/ Z j2 n$ d3 V: a5 ] L. v5 UPath = Path & f.Name &"<br>"
3 \' A5 H, H) fSet f = f.ParentFolder
5 t/ U, P: h. Q( e. F4 Wn = n + 1
7 N; q1 M/ I+ M- n2 k! uLoop
% l+ G" p# K3 \$ f! T9 \5 Z5 \DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path ' c* b1 k& }- ]2 C$ B+ g
End If
$ o! ?1 @. L9 I- R& AEnd Function ) t/ U& G3 E( s: Y- n9 K! N& T
' z( M0 f4 N9 ^* `% s'========磁盘操作========
( z0 x: a9 H( K- Z9 N, r6 T'驱动器是否存在? + q; t( w8 _3 S; ^9 \4 @9 {
Public Function ReportDriveStatus(drv) ( }' U% \0 O* y3 ^" H
Dim msg
( W" V( B! _: ~5 c) Hmsg = -1 2 Q2 n* J# M& q) M3 W) m
If objFSO.DriveExists(drv) Then ! X' f+ I! Q( f% R
msg = 1
" L6 F* J& M2 o; d5 l- p$ oElse
$ f6 @" A& i! B M1 omsg = -1 # f" H' s$ L/ ] M
End If
b9 _5 J3 Z% q0 b' VReportDriveStatus = msg X; q4 q; P" L& S- A4 P7 k
End Function $ k$ `$ `# z2 y+ e$ U
' ?& X9 v! M, u. }' H5 n
'可用的返回类型包括 FAT、NTFS 和 CDFS。
+ X7 u7 m9 o1 U) n# g* E1 HPublic Function ShowFileSystemType(drvspec)
& [# a1 W* u3 `/ N, n* }! HDim d
1 K# H$ @& N6 p7 N+ U; VIf ReportDriveStatus(drvspec) = 1 Then
0 p3 j' I# I, M: C/ r, j5 [Set d = objFSO.GetDrive(drvspec) % P+ |! @; u3 D) Y2 \/ a8 ^' i# O# K0 g
ShowFileSystemType = d.FileSystem / z# O+ t8 s$ R1 t: J. B' t5 e# q
ELse : e& T. z8 r3 _/ w8 v) k: L
ShowFileSystemType = -1
: n, Y- Z5 Z$ x& M" D/ P6 YEnd if . P% Y8 [: g/ T o
End Function
7 \8 f. ?# `8 v" H5 l3 ?End Class 4 M: c3 b$ A% Q; X; Z. C
%> |
|