- 威望
- 9151
- 在线时间
- 1302 小时
- 金币
- 7308
- 贡献
- 615
- 存款
- 660001
- 最后登录
- 2026-7-16
- 注册时间
- 2006-5-10
- 帖子
- 1875
- 精华
- 4
- 积分
- 25896
- 阅读权限
- 200
- UID
- 10
   
- 金币
- 7308
- 贡献
- 615
- 威望
- 9151
- 最后登录
- 2026-7-16
- 帖子
- 1875
- 积分
- 25896
- UID
- 10
|
ASP文件操作大全" g0 B& Z9 l$ `/ s
<% 9 j1 D2 j+ [' j
Class Cls_FSO % U$ f: F" v* e; i
Public objFSO
- F2 T+ p+ S! {* h7 F# n/ xPrivate Sub Class_Initialize() $ p* D& o" E0 K, x( a: ^! e
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") * O: q1 `: ]( P1 z) ]3 b
End Sub
! |" f* ?* R3 t2 yPrivate Sub class_terminate() + p" x$ R% ~1 ]9 U3 g+ f( p9 l$ }
Set objFSO = Nothing
; V" E4 m+ ^$ wEnd Sub
2 j' t) i& p! e& G* Y3 ?3 q% x% J
% a" v6 |9 K8 W1 X. N" n3 [) R'=======文件操作======== % i9 V9 e0 h9 h+ B+ A! S
'取文件大小 # Y6 m# I2 c' w6 T
Public Function GetFileSize(FileName) + [/ X1 M4 m/ g
Dim f 9 j) L7 ~0 T9 l
If ReportFileStatus(FileName) = 1 Then ! u' B2 f8 I* l5 x% ]$ q
Set f = objFSO.Getfile(FileName) - v; K |8 s0 _ S8 L9 q
GetFileSize = f.Size % D$ |. s8 { g1 ^7 F. `
Else
]* U1 }+ Z' J6 `GetFileSize = -1 0 K5 P. ~' [+ h7 ^: y) `
End if
" F0 [* p# ?5 X5 ~1 @6 N4 NEnd Function
; S" O, j4 l! z
9 ^, t* F- R. p, N6 T; @'文件删除
& w. C8 n7 ], L( _3 @( p2 T; EPublic Function deleteAFile(FileSpec)
, ~8 l( k% O, Q! U& g8 YIf ReportFileStatus(FileSpec) = 1 Then
9 F: J2 d. o7 l) X* Y: j, ZobjFSO.deleteFile(FileSpec)
/ y) [) e4 ?) Q8 ZdeleteAFile = 1
6 m* P4 G D' j9 H4 }8 LElse # v+ V' t$ N) R- Y
deleteAFile = -1 ' ]" o. \2 z* l) X9 J1 w/ {
End if ]! Y2 D- }3 P. \5 q% _4 D
End Function
! p, U% ]& n3 N) R" v& G% G9 z5 I w% ?6 s7 }
'显示文件列表 ; Z4 I1 b8 _( ~4 T7 ]0 h9 }+ W4 F; ^
Public Function ShowFileList(FolderSpec)
/ o" K6 J& p! r) [5 W. M# ^0 EDim f, f1, fc, s % u% q5 D3 z9 Y
If ReportFolderStatus(FolderSpec) = 1 Then
& t8 ?) l* J* {) L& DSet f = objFSO.GetFolder(FolderSpec) 3 V) A7 ]! I: o
Set fc = f.Files
% A% {! m5 U0 { n" KFor Each f1 in fc
4 Z$ T. H0 ], \. v" ps = s & f1.name
+ }% V) u, m: t8 d- M7 j$ [$ hs = s & "|" $ R: b0 f9 U5 r7 ~9 X! I
Next
: h4 G$ t) C) cShowFileList = s 9 G) N0 P/ i; \3 d) w
Else
7 K: f- B# x }0 P1 J$ dShowFileList = -1
* o r; ?, s/ u6 aEnd if % s9 p$ b+ V- t* ^, m
End Function 9 W- U4 K. P9 N% E, D. B
1 e/ K# `+ u" l8 K; g- P
'文件复制
0 ]% s7 @+ S' B6 _& APublic Function CopyAFile(SourceFile, DestinationFile) ( W6 }/ {" e. \
Dim MyFile
+ ^' a3 ^! h8 gIf ReportFileStatus(SourceFile) = 1 Then
- Y; x% h2 {$ j& iSet MyFile = objFSO.GetFile(SourceFile) ' M" q- B$ G2 j( H, b* H
MyFile.Copy (DestinationFile) % p( P+ H2 M& |4 B! {3 S
CopyAFile = 1 # p) k) Y, V B$ j# z% f- n, }
Else : H* u" W$ B" t% v4 T c
CopyAFile = -1
6 {/ i# K+ g! [+ s3 Y* kEnd if
3 B/ ~" b1 }7 }3 C; I5 N6 y+ b+ XEnd Function + L2 o* I- k- U4 F4 p$ P! e6 i
9 W. r6 c0 a6 x3 E$ Y8 ~ B8 w. ~+ E
'文件移动 # D! u1 ]5 E6 ^3 j7 @1 u
Public Function MoveAFile(SourceFile,DestinationFile)
2 j; M; E Y+ G5 S( j* J2 t$ OIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
% A8 b: }8 Q3 }- l2 g: E. g( Q* PobjFSO.MoveFile SourceFile,DestinationFileORPath 2 G" f) o9 c' e! L+ U% a2 x' o
MoveAFile = 1 Q( {$ J4 c7 L I
Else
0 x2 p2 i# N) `7 yMoveAFile = -1
. J- L" |- l5 y, JEnd if
6 S3 }( R& J) _" Z7 o' pEnd Function , f0 S& o w7 {! h% a6 C7 i2 l9 `
' a" k1 s& E6 D
'文件是否存在?
6 j' ~* [/ v$ u2 z4 G; jPublic Function ReportFileStatus(FileName)
; m o0 Q0 \/ v8 N l: c: NDim msg ; {" E- y0 n9 g/ A
msg = -1
- d' X) |8 u" J$ Z S' K) PIf (objFSO.FileExists(FileName)) Then 5 \( M+ v' Q& G$ q1 q0 @3 O
msg = 1 ( `: C, ^8 n9 k* B& G
Else
9 M9 `% O4 T- g6 d4 m* C+ smsg = -1
* F( @2 P- e9 }End If - v5 a% p f/ m8 W
ReportFileStatus = msg
6 t- y8 ~- e: l5 W3 ?, ~End Function
: X, Q# D9 G) m# m+ S+ G. X! ^; ?6 \( C6 F7 Z# g+ `& y/ Z
'文件创建日期
' ]" A6 A) F- N2 FPublic Function ShowDatecreated(FileSpec) 6 e3 o+ b! N1 |- M7 s* F) e7 _
Dim f ( V2 v8 d" P2 _) i" r6 Q& h! F
If ReportFileStatus(FileSpec) = 1 Then " o5 A: J0 Y9 N; ~1 z! n& S
Set f = objFSO.GetFile(FileSpec) ) T) R2 N& d' e' M$ r5 Q
ShowDatecreated = f.Datecreated
1 `5 g# L. T! F( X$ kElse 1 F7 }( Z8 i* I. x( g+ L
ShowDatecreated = -1 $ S0 j% ?) \. H3 |( {1 F- a4 {5 U
End if
1 o3 d0 o7 ]! O* N7 C1 ^) f6 NEnd Function
- M4 N" X/ S& T v" c/ ?: J
3 K' l( _( J( b, D'文件属性 * W2 ^* S; D$ |4 N
Public Function GetAttributes(FileName) 4 n6 N0 `* ^% O
Dim f : r' A* I) X2 o; x
Dim strFileAttributes
{+ X. N9 W3 ?2 |If ReportFileStatus(FileName) = 1 Then , z5 Z& m9 ^- Z X
Set f = objFSO.GetFile(FileName) $ \- F0 D7 Q& F% E+ H9 x. w
select Case f.attributes 3 i4 V' F% ~/ E0 R4 B
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " ; }% K' P& p: [) l
Case 1 strFileAttributes = "只读文件。可读写。 " ' v& |- U) f; m6 C1 X
Case 2 strFileAttributes = "隐藏文件。可读写。 "
5 k3 y$ O; U: j. p7 q7 W% z/ DCase 4 strFileAttributes = "系统文件。可读写。 "
" C1 v% Z: v9 b7 z0 PCase 16 strFileAttributes = "文件夹或目录。只读。 "
5 {+ B E( ?; `- ?. ACase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
2 v* O) B2 ? k8 i% r) i1 gCase 1024 strFileAttributes = "链接或快捷方式。只读。 "
$ L+ c$ D6 R8 lCase 2048 strFileAttributes = " 压缩文件。只读。"
2 k2 l$ T/ f5 y) ?2 d- F( YEnd select & V* ^! y; w, f# Z
GetAttributes = strFileAttributes
; u, `( s( M* E4 w" H' ]Else # A1 \% d2 ~$ z$ ~, m" B* ~
GetAttributes = -1 . f) k5 D( `* I5 R* {& `# [/ x
End if ! I3 D. N* y4 Q
End Function
- J' v+ S. Q% ?# ]& a7 M y0 J1 l( l4 @, j5 a* A
'最后一次访问/最后一次修改时间 ' N- ~ U* q( m+ S& \8 N
Public Function ShowFileAccessInfo(FileName,InfoType) 5 s! w1 C: T; N+ B& n
'//功能:显示文件创建时信息
/ P0 X, e5 g4 ~'//形参:文件名,信息类别 : o# ^9 H, ^5 U
'// 1 -----创建时间 4 `) Z q: @3 g/ L7 C2 f2 B8 A
'// 2 -----上次访问时间 , V( o/ M# G. m8 @: e
'// 3 -----上次修改时间
( j* l) |9 H* B6 S h# p'// 4 -----文件路径
0 r5 o* C$ s/ e# K# s'// 5 -----文件名称
W5 x% p, s6 ^& |: }'// 6 -----文件类型
5 Z3 R' M: d5 n' U+ T8 }'// 7 -----文件大小
; ]. m' g3 M1 W1 }$ a' Y( }' z'// 8 -----父目录 3 C! N( p: }$ w* t. p) o
'// 9 -----根目录
( V- c. q# i2 T/ I+ hDim f, s
/ b/ {/ n4 D, ]5 l1 }If ReportFileStatus(FileName) = 1 then
; [* n3 T& P( WSet f = objFSO.GetFile(FileName)
! H% x7 U/ X8 h9 |, m" Tselect Case InfoType
- ^! S$ J. Q1 P6 oCase 1 s = f.Datecreated
& r1 l! c7 P% M3 u* UCase 2 s = f.DateLastAccessed
5 }7 A1 n$ H+ @ Z) \Case 3 s = f.DateLastModified , S% x8 _5 I0 t8 t
Case 4 s = f.Path J: ^% |3 t$ {7 Q9 |
Case 5 s = f.Name , K7 v; M2 s) x% |9 D
Case 6 s = f.Type ( l: ^9 L! _: y0 C: N1 u
Case 7 s = f.Size ; J) ^1 C% Y! M2 O* x
Case 8 s = f.ParentFolder
& h) n/ A% v* g6 o' E8 a' w' b9 XCase 9 s = f.RootFolder
: B, _+ i6 L; M0 ^End select
- s8 I9 }4 o5 T4 {3 U9 C# d/ _ShowFileAccessInfo = s
! p3 Q+ J. \; D+ d6 T/ gELse
/ K6 B6 l) c" t1 P" I% V& i/ tShowFileAccessInfo = -1 , m6 O% B" J2 i# H
End if 2 R/ y/ n, a% Y$ c4 J( B
End Function 4 h+ V: X# E! d7 d! x9 h* g9 v
' n& `3 b+ `% \, y1 d'写文本文件 ' |( I ?, q: v* Z
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 0 i( x9 _$ n+ c; W+ s; i
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
2 y; w2 j% }& y5 b0 eDim f, m
* |! ?. F8 g# Eselect Case WriteORAppendType * s- m U0 D9 d
Case 1: '文件进行写操作
3 a, a9 }4 X l6 E3 t: Z. ]0 YSet f = objFSO.OpenTextFile(FileName, ForWriting, True) ' t6 x. C' ?8 Z# t
f.Write TextStr * [# b5 u3 p& {# H0 W2 M
f.Close % y- s# C7 B! w0 Y
If ReportFileStatus(FileName) = 1 then . q0 n5 O5 }3 j O6 {
WriteTxtFile = 1
. H' K; ~5 F6 x' d3 wElse
8 ?; a! w9 x- f/ |% p* ZWriteTxtFile = -1
/ A+ X3 J/ F% y) gEnd if
1 i4 L) ^. [ {$ L {! JCase 2: '文件末尾进行写操作
+ z# @2 @6 L7 F# dIf ReportFileStatus(FileName) = 1 then . _. b8 }: G% _, R- N+ g
Set f = objFSO.OpenTextFile(FileName, ForAppending)
7 i& H( e" ]% ~f.Write TextStr & E% G; P( h( z: \) g7 s
f.Close 7 C( A! r6 I5 `+ U) E0 \4 O
WriteTxtFile = 1 1 y. _' z$ ^* w- G/ }# b) Y
Else
7 m1 K% I9 l- |# d! V" [1 }/ aWriteTxtFile = -1 + `0 v1 b3 f6 E7 h
End if
- l1 D# ~# p! i$ O' rEnd select ; j8 G+ U; C9 A3 b% M+ E5 y
End Function
& I( Y" l u' B
* O3 @0 H8 \2 d'读文本文件
; Y E% y8 ~, a+ @2 [2 [( Z4 mPublic Function ReadTxtFile(FileName)
& P+ s2 ^' `4 }, @Const ForReading = 1, ForWriting = 2 ) w& w d, t0 k! J M( F! V# w# D
Dim f, m
. X& U* C& X- aIf ReportFileStatus(FileName) = 1 then
* a1 w S9 f7 X4 G% |Set f = objFSO.OpenTextFile(FileName, ForReading)
5 K# U# j) L e/ F0 a% |/ \m = f.ReadLine 2 w, Y3 v' `, b. S& e
ReadTxtFile = m , S! M; A3 n5 t$ }
f.Close
| i) |! z5 ~( i! _) a% p5 qElse
7 P5 E& T" A$ V L1 Y uReadTxtFile = -1
- G4 @, `+ O* }3 N. X! E2 l1 o0 PEnd if % C" q! v6 z9 Q! G9 j, B
End Function
* w: Y& H# g! G# {; c H8 d! U7 T
'建立文本文件
9 S7 A+ j7 D) v9 z9 D( N% H- u: |5 c
'=======目录操作======== 8 C5 Y1 G) S% K! q
'取目录大小 & H* Y h1 @# {+ ?: N( I
Public Function GetFolderSize(FolderName)
" e" ~3 }" `7 E3 E% x# kDim f
& [1 @0 p+ S2 n9 W- ~" VIf ReportFolderStatus(FolderName) = 1 Then
9 ], w* A3 G4 t. V' R9 GSet f = objFSO.GetFolder(FolderName)
' d- N' b* `& @3 U) g3 rGetFolderSize = f.Size
x/ s O: ~. T1 H. N9 Y3 ~( F; ?, ]Else 5 W1 E* Y5 |9 Q/ k
GetFolderSize = -1 , s6 M- X+ {8 e! _- S, J$ }
End if
* P# O/ Z6 v1 xEnd Function ! v6 W: v, T- P( y5 k/ K, _' t
) n8 U3 R2 G! z3 l
'创建的文件夹 3 b7 x" \) s4 w! }0 X9 L
Public Function createFolderDemo(FolderName)
w+ s0 u+ H4 T0 LDim f
$ U3 U, i. ^/ [# XIf ReportFolderStatus(Folderspec) = 1 Then $ p. W7 z3 f& T% Q$ S
createFolderDemo = -1
# g" n' N: s1 t" cElse / K2 W) o- G9 x7 T
Set f = objFSO.createFolder(FolderName)
. x0 `9 I7 x ZcreateFolderDemo = 1
0 E `: a9 }- {' ]" v9 ^End if $ B1 z0 S! ]8 _6 q$ w
End Function
9 Y+ g3 |; T3 P* b' c7 A& Z1 ?: d
'目录删除
/ C5 o1 x* l$ ]! v8 G3 kPublic Function deleteAFolder(Folderspec)
/ c/ N7 e7 h: W; hResponse.write Folderspec 7 q. {. G; V; e& K' J, X1 `
If ReportFolderStatus(Folderspec) = 1 Then
1 _& S% m0 H. @4 V% l1 R/ x% n- \# hobjFSO.deleteFolder (Folderspec) # [. z$ u* p% q- p
deleteAFolder = 1
& C l9 U, [0 V0 s1 uElse ' `+ ^: |- M9 c* q% k
deleteAFolder = -1 : ]/ g: y5 D& J4 t/ J
End if $ ?! _# A2 q, z, g; _
End Function # n! I9 M9 o5 M& {2 O* x, L
+ K; Z0 b$ [. h9 N'显示目录列表 % w& h) P9 V T0 f; Z8 Y# W; S
Public Function ShowFolderList(FolderSpec) + z" X+ V7 w3 n9 T
Dim f, f1, fc, s & ]5 ?9 v+ m# f w! y" I
If ReportFolderStatus(FolderSpec) = 1 Then , T2 |" w/ d6 R- L0 @, o5 b2 X/ w
Set f = objFSO.GetFolder(FolderSpec)
) k. G2 z* Q1 c) t) I2 nSet fc = f.SubFolders
% c# W( y* U. j& `: ZFor Each f1 in fc
: b9 o+ g; c# ]* c2 E1 As = s & f1.name
* y) S8 C2 I+ `- U4 b+ @# N8 Cs = s & "|"
9 R2 B# C. |5 K% G) Z% i- qNext % F* G/ V+ G9 e, Y7 F9 ^/ A9 R
ShowFolderList = s
, w: g9 C6 p- l: |" B# RElse
& H/ i/ ^, c5 Q' D/ dShowFolderList = -1 / e% [; I; \) w% u1 E& T( K
End if
4 O% w, r1 k. G0 h) x( dEnd Function ! r; O) i& P7 C) l
" n1 `4 |4 [! @9 y' ?2 i
'目录复制 7 O+ ^$ n$ N" d+ ?$ H
Public Function CopyAFolder(SourceFolder,DestinationFolder) ' U& L5 [# t: Z
objFSO.CopyFolder SourceFolder,DestinationFolder
" T. M" d6 k! H W, p8 X: r! l& m7 xCopyAFolder = 1 $ h/ }: M% ]6 H, r/ q$ y
CopyAFolder = -1
" n$ k% d, a P5 y# h4 o8 v5 A3 tEnd Function
0 r0 K$ U9 e3 D3 D! z8 J; d4 x! q R/ o% i+ a
& {: L7 X2 l% G' I m+ X5 R8 k- ?'目录进行移动 $ h# l7 W, M% T2 v" `/ j& c- A: ]
Public Function MoveAFolder(SourcePath,DestinationPath) 0 d4 R; j! u# T! s9 j
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then + J0 g' |* y+ ]4 ?$ i! H
objFSO.MoveFolder SourcePath, DestinationPath 0 X3 ?! X u# m
MoveAFolder = 1 ' }1 ?5 e0 L' e- q F
Else
' C3 G& u# a0 @7 F1 y1 x4 H0 q- dMoveAFolder = -1 & Y5 X& X' n7 e8 K5 X. [
End if 3 p5 R4 ]. c) G1 q4 i- t
End Function : `# T% E4 \4 @3 C% W, I N& n" q
9 O& c2 E+ H) Y `/ q) ~'判断目录是否存在 ! R& o6 g. M2 ~
Public Function ReportFolderStatus(fldr) 5 X! P3 r% p) r! @0 ^; W: Y ~
Dim msg 3 }" }. `, P% T p; f y9 X
msg = -1
7 H/ D3 i% p, h, @( y7 @: s5 QIf (objFSO.FolderExists(fldr)) Then
7 C! E @4 C3 H/ Z9 s5 c+ |msg = 1
7 z w1 e, ]" U8 UElse - L, _2 j# I% G
msg = -1 ( l5 C A+ f- R* [& W
End If
2 ]* ]% {& X9 ?, I- F# U% WReportFolderStatus = msg & y' c8 Z7 Q, |) L. V
End Function
' f: B5 ]5 `- k, Y9 d) p8 b& n- o
3 ~: b1 s4 o) q'目录创建时信息 9 A" V6 G9 ~4 M( E, A8 M% b
Public Function ShowFolderAccessInfo(FolderName,InfoType)
7 C& T9 ^( U, e H: E'//功能:显示目录创建时信息
5 m5 Y% v _# t7 k'//形参:目录名,信息类别
. [! @6 |7 [$ D'// 1 -----创建时间 7 ], l k6 _7 d* F
'// 2 -----上次访问时间
& c ]1 G7 c; G& }; t'// 3 -----上次修改时间
: j7 a8 }/ k, U/ e'// 4 -----目录路径 8 g( R& I( b0 g
'// 5 -----目录名称 8 L8 j8 F) B+ n/ z
'// 6 -----目录类型 8 v6 F, [5 U0 U* D: _
'// 7 -----目录大小 5 k# S! n' E4 N+ u
'// 8 -----父目录 & Y* E. V1 k5 A* l7 X
'// 9 -----根目录 7 m* c4 k8 g8 | H# i7 A) _5 w
Dim f, s / n7 P, H9 ~4 q, d4 Z! E
If ReportFolderStatus(FolderName) = 1 then v3 O7 I0 }! ]# c+ \. g
Set f = objFSO.GetFolder(FolderName) " c# U6 M4 ~4 i# L
select Case InfoType
$ U: q/ y. U6 [: h# PCase 1 s = f.Datecreated
7 m& m3 j* V3 z; k; ZCase 2 s = f.DateLastAccessed 9 Y0 U4 W8 j, b! b
Case 3 s = f.DateLastModified : f2 \ D! f1 I! T
Case 4 s = f.Path ! H2 v m, ~* F0 @
Case 5 s = f.Name
. d( F1 {, N( a5 ^. ECase 6 s = f.Type
; j3 c& C( a \, A" l" oCase 7 s = f.Size
4 M! I) G& k. n# R, f, C: J' ]9 hCase 8 s = f.ParentFolder
# V9 g R' P" ~0 f3 t( H2 d' X" ICase 9 s = f.RootFolder
$ W6 ]8 h/ z' y# b r) W' a' wEnd select
, R0 \. k4 R' y1 M" w8 xShowFolderAccessInfo = s - V& Z) Q: K0 P$ a" E" q7 f. r) P, w
ELse
# S, e# j4 Y4 g- C5 T( p0 AShowFolderAccessInfo = -1 , W) h' K% V3 @# ]! ?
End if 1 t5 } O& b( I( `1 A& p
End Function / ~4 Y G6 }# W* g
. O7 q! H8 R/ B/ Y
'遍历目录 $ r C+ u7 l; |9 J) }+ X( g
Public Function DisplayLevelDepth(pathspec)
0 g9 e8 m& X; gDim f, n ,Path 7 _$ I) s" I! T" v! V* H, R
Set f = objFSO.GetFolder(pathspec) , y* [. i1 g$ R/ |
If f.IsRootFolder Then
, [5 K: L6 t ?1 C0 x( ~1 P- TDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
' }: e4 V/ v, V% WElse
5 j+ x* Y8 m9 c B0 [Do Until f.IsRootFolder
# s+ _8 h3 X6 c. _# |Path = Path & f.Name &"<br>" # o# F! N# C O( I3 W l5 N
Set f = f.ParentFolder
, m# d' m0 S# q0 Z* ]3 Yn = n + 1
8 \( p4 G. G" XLoop 9 `. y O+ |9 i5 D7 c: o% e/ s- E
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path " l/ c6 k$ X; d- w: _4 b- n
End If 6 F( w) R% Y, G& i& {& Z/ Z8 O2 I
End Function
2 I/ o4 V( |5 e2 P! Y# T( y
' E6 r2 }. E0 ~9 Y'========磁盘操作======== $ H8 `) d! `( \0 R) x
'驱动器是否存在? ) e; z7 G( l) o. g, @
Public Function ReportDriveStatus(drv) ( t; `. x! z7 T1 f' l
Dim msg # f. F$ \* y" j; X( @$ S
msg = -1 0 k; ?3 n( p* h, z
If objFSO.DriveExists(drv) Then - s. K4 D; ~" m2 M# q# h
msg = 1
: y; L+ j: v+ N8 ?Else
- _& V5 B; `! vmsg = -1
3 w0 u& K" _' e* \) L+ aEnd If
, |8 c' `# v. R; |" S5 _3 FReportDriveStatus = msg + {( c; t5 G a) \8 }
End Function . o! c1 M: N7 w7 R
7 g) }, c% K6 p6 k/ u) x'可用的返回类型包括 FAT、NTFS 和 CDFS。
9 e( W' w) N+ P& V! [5 [8 iPublic Function ShowFileSystemType(drvspec)
5 r2 y/ t$ ]+ c t3 fDim d 9 \6 ?: ~; z* ?) b; w( a
If ReportDriveStatus(drvspec) = 1 Then
. n) Q' I/ C+ C4 q kSet d = objFSO.GetDrive(drvspec) 2 o! t8 @5 Y, {. R$ u
ShowFileSystemType = d.FileSystem 7 \! H1 T; W6 [' r% n8 `
ELse 8 S5 |8 b8 \" R/ u5 N
ShowFileSystemType = -1
+ b# Y# _- T5 N- b7 m/ u( @End if
0 F5 J% z1 p' U8 H: aEnd Function
2 d# j6 q X% c( g& [( cEnd Class 6 g5 H7 Q$ Q: Q3 D$ W
%> |
|