- 威望
- 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文件操作大全
' ?, V/ B2 D6 s<% * Q) \. L! l3 x
Class Cls_FSO
7 X4 `( \: R6 s; o7 IPublic objFSO / C# N+ D" J- s
Private Sub Class_Initialize() , f! ~1 T; d7 s
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
$ a- u* K1 r8 X2 q6 P1 [End Sub ' V# g: H) z$ L8 Q) |# e
Private Sub class_terminate() 9 |2 ]7 ?" e' H
Set objFSO = Nothing
/ d1 M8 ~1 k" f8 i6 u% `End Sub
6 H4 Q O4 X9 J# e. E7 p, ]' X |
8 _& W' }( Q' |: l3 J" d! a'=======文件操作========
" W! T! ?0 Z' k3 _* z$ b4 U'取文件大小
: ]. z y& X- {3 v7 n/ ^Public Function GetFileSize(FileName)
: d& @1 o8 O: NDim f
9 r; Y5 i3 M: k1 sIf ReportFileStatus(FileName) = 1 Then
8 Y3 N }$ ~% n& j$ t4 CSet f = objFSO.Getfile(FileName) / s3 r0 Q7 E+ ]5 J- v
GetFileSize = f.Size
9 u/ ]: }5 k5 d$ Y2 p" F8 qElse 2 d/ t# q# I5 g: O. [) Z7 D. \
GetFileSize = -1
- h' E; G1 r9 R. kEnd if
0 D* @, B; w4 N- K3 }6 A" _End Function
$ n+ I" N+ G; u' I9 \
5 R0 s) L8 u5 ^- E& z% r; n'文件删除 4 D1 c) C0 ^, y/ R
Public Function deleteAFile(FileSpec) 4 W6 y, e$ A7 w# f$ _
If ReportFileStatus(FileSpec) = 1 Then ! o4 q, t9 n5 b: o6 D
objFSO.deleteFile(FileSpec)
0 \5 a8 ~0 p5 u; v2 _deleteAFile = 1
6 j# k) J6 c9 f& Y1 N" V( h4 ]. AElse
! C' u% D! b7 k4 V6 r# hdeleteAFile = -1
# }+ g7 J4 e2 v( H+ R9 T; BEnd if 6 N* O( n P- w# x. C2 x
End Function * B2 _( y Z! k9 u/ A" I
: q& E/ \: g; K; x% N
'显示文件列表
" k( R0 U, E% t, J ~- SPublic Function ShowFileList(FolderSpec)
; O8 P* T3 e' Q$ jDim f, f1, fc, s 2 G3 o" S8 }: B0 w/ r- ]
If ReportFolderStatus(FolderSpec) = 1 Then 2 g2 N8 Y6 l4 n# t: F
Set f = objFSO.GetFolder(FolderSpec)
( S/ K/ @2 d( @/ b8 j9 ESet fc = f.Files 4 l. F6 }0 n( E2 K0 P
For Each f1 in fc - A+ ~2 C2 Z$ r$ H. M8 r
s = s & f1.name & \: A, x' d; x" N; c
s = s & "|" * S8 O, i8 D$ \5 f) O2 O
Next
' ?4 L' |0 e8 \" c4 JShowFileList = s ' w+ @( \6 @; u2 A7 N' V* {
Else
" E1 m$ Y+ Q0 g# m0 T' ]ShowFileList = -1
1 l; u8 \8 m" @. i+ M; W8 ?End if
$ {' d; g" [6 f$ k& h( TEnd Function
/ k" ?0 K, `; Z* k( _( M4 S& [: C" W' x& {7 A2 K
'文件复制 / k4 _- E- V& _" Y. g
Public Function CopyAFile(SourceFile, DestinationFile)
- |8 Z' o3 a s+ L. P+ rDim MyFile # k- ~; d7 I6 B/ T K
If ReportFileStatus(SourceFile) = 1 Then ; D" D3 w5 t: G! u% v" g
Set MyFile = objFSO.GetFile(SourceFile) & x- J4 w" ]9 A( x W% E$ x9 m9 H
MyFile.Copy (DestinationFile) ' G3 I7 G' I. c5 h( y# [6 p
CopyAFile = 1
1 V$ m8 l/ m, H# k3 f3 x4 {! jElse
+ A" I" p7 U& }, p. E0 ?CopyAFile = -1
& A* h1 P0 h V0 o0 MEnd if ! Y* [1 \; N5 F0 Z6 \
End Function
( z5 ~7 c* r9 z6 Q1 m# n% z. X9 S+ d4 f* Z5 l: ?& x9 {& h
'文件移动
3 c- o8 n- y; ]# {5 T! FPublic Function MoveAFile(SourceFile,DestinationFile) ) ?8 |8 X8 ?" W6 H/ h! @
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then " p! d9 g7 i' o" a6 t& e
objFSO.MoveFile SourceFile,DestinationFileORPath # i7 A5 m- N9 _
MoveAFile = 1
7 z. ]/ [6 V! IElse
; ^, o! L$ y& o5 E q9 |MoveAFile = -1
# B( M# F8 n$ N1 OEnd if , r O1 r" S* Y2 z
End Function 4 H8 f: j. \. v# u
0 C: E! I% j' P1 U) u; ~% |'文件是否存在? " a; ?1 i9 {! e* T# T: h
Public Function ReportFileStatus(FileName)
1 p: ]3 G! x j- CDim msg , p/ V5 w2 b2 O/ y
msg = -1
, @0 ?' B' D1 r% l* ?0 `If (objFSO.FileExists(FileName)) Then
2 a/ T0 u0 R! D6 a7 u- y' s `5 emsg = 1
$ z) C2 l$ q# s& `Else
1 K/ S( g; p8 @; ^( l3 rmsg = -1 * s7 e2 o3 |+ x R2 r- D
End If ! N% G0 v; U0 r7 y
ReportFileStatus = msg
, J3 n' L- x9 a6 zEnd Function
# m- |6 W4 C& p% y. P5 U! ^. |4 d) b5 \
'文件创建日期 7 r& Y6 ]9 H8 _7 n5 U! w P7 W
Public Function ShowDatecreated(FileSpec)
4 \9 l$ w# T. _, |. R& X ^; BDim f
0 G" `& N# S/ h. T* |If ReportFileStatus(FileSpec) = 1 Then 8 o4 \& g, m+ i7 q2 `
Set f = objFSO.GetFile(FileSpec)
' f, ^- m- f2 h+ y" i8 ]ShowDatecreated = f.Datecreated
8 b6 m2 |# Z7 n3 N2 QElse $ |: [5 s0 Z, S! [6 i* e5 G
ShowDatecreated = -1 # o: a$ Y l/ G0 L! u
End if
( ?# O+ S6 g' N& {8 bEnd Function 8 y0 S3 G8 I3 \. ]4 t
4 N) N1 u! ]' y7 S6 r) s' {! g
'文件属性 / v* v8 d; t: R3 d
Public Function GetAttributes(FileName) / A# e2 {) T7 I0 n, O( e
Dim f 1 v7 ^! D" C; j$ e9 X4 V
Dim strFileAttributes : \1 H) L8 O. C. ?6 W! K' Q
If ReportFileStatus(FileName) = 1 Then
I* N/ a5 ~% ?2 OSet f = objFSO.GetFile(FileName) + I! L& l2 `! {6 w2 h) [: H. {
select Case f.attributes
1 ]/ x1 d' R' i6 `; c, ZCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
" C) M, n/ ^9 HCase 1 strFileAttributes = "只读文件。可读写。 "
" z8 o5 E& J: e# s% ?Case 2 strFileAttributes = "隐藏文件。可读写。 " 7 i8 n8 ~' p I" y! j3 k
Case 4 strFileAttributes = "系统文件。可读写。 "
, H! X; y, ?5 ]% D* f" e5 W. t5 kCase 16 strFileAttributes = "文件夹或目录。只读。 " - i' s; D; k7 ^6 |: z1 J+ s7 G: J
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " 1 G: D% p9 r6 y; ~3 E
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " ! C [! w" S1 w2 {4 a
Case 2048 strFileAttributes = " 压缩文件。只读。"
2 {7 P8 D3 Y) E% P, XEnd select 2 x ?8 v" ~% O+ U* Z
GetAttributes = strFileAttributes
8 m+ O! [2 s& k! e0 }' K IElse
1 w6 c& u3 z# X# Z6 T9 P/ _2 _GetAttributes = -1
% \4 B) u5 Z3 G# |% @End if ; g. U0 h! {$ x
End Function
8 R2 e- J+ o' J9 N J& {, s0 q- ]& g% i4 k. }
'最后一次访问/最后一次修改时间
% g6 V- O: p9 D* d1 Z; I0 ~2 i- P2 fPublic Function ShowFileAccessInfo(FileName,InfoType) 3 p- N2 w, C B
'//功能:显示文件创建时信息
4 h* t1 i Z/ F'//形参:文件名,信息类别 - C+ C& D' [ v U" W/ H
'// 1 -----创建时间 . g6 r: L) W7 R1 T8 l
'// 2 -----上次访问时间
) ?9 P# @; ?8 J8 X/ o" i'// 3 -----上次修改时间 . V9 W' P$ j' C- f' `, i i$ [
'// 4 -----文件路径 / A: V+ x& Y9 x
'// 5 -----文件名称
8 P' c. ^1 U3 f+ o'// 6 -----文件类型 # u5 q: X0 s9 _" a0 `
'// 7 -----文件大小 9 M+ _% ?3 a2 o" W$ ?% o
'// 8 -----父目录 8 M) C, A; f) _7 Y
'// 9 -----根目录 ' T/ o" ~. x( N& M
Dim f, s . P/ z$ u1 L+ G e
If ReportFileStatus(FileName) = 1 then
) L2 w8 m& p$ |: b% ]Set f = objFSO.GetFile(FileName)
; o, q$ c3 G, c; I# F, {4 Aselect Case InfoType , K `3 I0 ^7 a7 Q7 x
Case 1 s = f.Datecreated
`4 \- W* N$ p5 w: t! E) d* cCase 2 s = f.DateLastAccessed 1 b/ A u5 d* A$ [
Case 3 s = f.DateLastModified
2 v! I; `4 W% P/ f) s. Y" fCase 4 s = f.Path 2 J5 t$ \' [& Z& K, @
Case 5 s = f.Name & y8 h3 t# r! H% Q
Case 6 s = f.Type 0 T4 Q: W; S& N0 {! ~! Z) B
Case 7 s = f.Size
+ l! n1 }# L2 u' q% i) i5 V1 HCase 8 s = f.ParentFolder
% I+ n6 X6 v- X+ K0 dCase 9 s = f.RootFolder 4 |1 {* r: R M5 j- I4 f
End select
/ j3 D" B" H, e& D4 [ XShowFileAccessInfo = s 4 G# B. F) X2 `; f
ELse
; C$ W; B* d1 K' o1 @. MShowFileAccessInfo = -1 . N6 [8 C% l- H
End if ; i8 a6 ~- x& M: S! Q
End Function
/ d+ q4 ]& _, v2 p& j0 |( j' O4 B/ d" g' N l6 t8 G2 K
'写文本文件
: v' K* N1 D# s1 ], B+ |% FPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) M* S/ w4 K& A4 {) H* j
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
r- {% Z: J1 [- `# _Dim f, m
; ]$ p/ a/ \. cselect Case WriteORAppendType 2 I$ R: _7 }& j! b. A
Case 1: '文件进行写操作 * q7 {& j4 S- ]+ K5 R
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
, j2 X3 N3 @, {7 j) Zf.Write TextStr
: ]% x: m* l6 T! P* ef.Close
% y! c- y6 x8 o5 Z$ CIf ReportFileStatus(FileName) = 1 then 8 J) B) ?$ n" C
WriteTxtFile = 1 0 B% k; z! r2 x$ O
Else ; R/ L' `/ S4 ]
WriteTxtFile = -1 : f+ f3 i& c0 J9 H% b) o
End if 4 ~* b9 T$ x z% z! h
Case 2: '文件末尾进行写操作 ( J3 Z) l1 `* o. x* A
If ReportFileStatus(FileName) = 1 then 4 j" a. k8 U& ~, q: [" V* S( X
Set f = objFSO.OpenTextFile(FileName, ForAppending) 4 X, l1 F. H/ _& q8 j9 X
f.Write TextStr ( M: h1 i& O/ O! U1 @& j. v* H( B* \
f.Close
9 _4 Z" s' }# u% }/ L& s6 Q% i1 OWriteTxtFile = 1
* W% J* X0 a$ h8 S5 a* e$ O1 @) {Else 7 | t: N" t N
WriteTxtFile = -1
& K O8 K5 a* _End if + i, L2 i6 S! V% g8 ~. o# i5 a
End select 1 O3 Y! R' f1 A4 s3 o
End Function 8 P% e/ ^4 u( v- \
) k* z; l; t6 k: w( H
'读文本文件
1 F1 |" h' z* T5 T/ ~6 F5 _) P1 BPublic Function ReadTxtFile(FileName)
/ [7 ^; S' q( IConst ForReading = 1, ForWriting = 2 5 t. \ X5 E; D+ S2 ?" Z
Dim f, m
w% |7 Y' A _6 O' G4 ?8 F. C3 PIf ReportFileStatus(FileName) = 1 then 2 w/ T" `! d+ m, Z1 w
Set f = objFSO.OpenTextFile(FileName, ForReading)
0 K9 @* t/ W7 p& h6 _+ R4 {, dm = f.ReadLine ( e0 ~( f y" d# F% N* R* a, S
ReadTxtFile = m
1 q ^ b8 j1 ^' Bf.Close % A8 M" `3 H- `% c
Else
0 s" ^ i' l' R% p M& m/ [ReadTxtFile = -1
/ c( z' C% Q, DEnd if
. R n, d9 z1 l: o4 k6 V) hEnd Function 4 v& y/ q% ~% i$ |
) |- d, t) Z' @; a'建立文本文件
9 M) ]: @- s5 Y/ B# Q _1 b# N; s
1 e4 `' e6 L6 m9 B5 W& W2 w& B'=======目录操作======== - c) R, \. \+ ]( E+ M, h# n/ R
'取目录大小 + _' j( I2 O) L+ Y
Public Function GetFolderSize(FolderName)
1 x) ?1 {) y h0 [" ZDim f 6 `. I3 t/ t, ?4 |' k7 {
If ReportFolderStatus(FolderName) = 1 Then
8 X2 u0 d& I- D/ KSet f = objFSO.GetFolder(FolderName)
$ u( e4 R$ }4 C% c% u$ ~GetFolderSize = f.Size
- }4 x: Y( @- w+ A# d& c' IElse ! f0 s, }. T! E8 ^
GetFolderSize = -1 ) h! z6 p& @' q: k0 v5 v6 V6 a; ?
End if
: c; q* t9 h" y9 c# e9 W# G# M0 DEnd Function
; K( j" p: d0 e
4 ]+ z+ b1 t. \7 n'创建的文件夹 5 X; d1 ^0 ?3 G! ]
Public Function createFolderDemo(FolderName)
8 I7 q4 I" X4 ?8 l+ vDim f
$ q( ~5 @- Z, O/ pIf ReportFolderStatus(Folderspec) = 1 Then
$ M% U$ t9 N. B/ J. ^( l* WcreateFolderDemo = -1 : k2 @( n0 v, j3 b/ Y
Else
2 j. i+ L% b* f1 Q- u4 S7 HSet f = objFSO.createFolder(FolderName)
. v3 {& y6 z6 v/ XcreateFolderDemo = 1 8 }- m6 S5 Y+ M0 X7 s+ t
End if
) _' t) @- F; d: w5 h. z- oEnd Function + j' F; E4 k: E+ w U
0 D8 {- D- i0 e" E+ q3 l'目录删除 2 Q* W, R, s! J; w
Public Function deleteAFolder(Folderspec) * U- C2 |8 D( ]
Response.write Folderspec 9 I+ \" X! }9 p
If ReportFolderStatus(Folderspec) = 1 Then
. T) e$ S. f$ h8 }objFSO.deleteFolder (Folderspec) 6 d% F: r2 G+ p. W. [0 B
deleteAFolder = 1
( a3 ]4 @; D# v( @Else - |5 Q- J- a4 H' g% N
deleteAFolder = -1
0 T K0 H' {( Y* ?. K( g: j$ [End if
/ s% {! _* Y) P* cEnd Function - @: q+ N% w5 J9 a/ {2 `% l
2 q, B% H6 n+ G( u
'显示目录列表 0 F. ]* j6 w" P
Public Function ShowFolderList(FolderSpec) ; o6 {) H" `9 p4 M" N$ S, R- K
Dim f, f1, fc, s : U3 H% z- c$ K9 |5 N0 {% f1 |
If ReportFolderStatus(FolderSpec) = 1 Then
- @. `& |( g8 w1 K* m& u; USet f = objFSO.GetFolder(FolderSpec)
& w! N/ K! j- f* Q$ OSet fc = f.SubFolders 6 h2 L. K [0 P
For Each f1 in fc 1 e' N* S* c, I5 N0 V& ?0 V B! M$ C. e
s = s & f1.name
3 u8 f @2 \7 m" r: b2 `, ^ d3 Ws = s & "|" 4 }6 @, Y% z9 h& A& {
Next 7 d/ R( v2 Q2 h8 ], G' Q
ShowFolderList = s
b: ^1 `3 u" _. Y/ r% }/ _Else
2 J9 [/ L1 r# G! F, E3 JShowFolderList = -1 " e7 M! r5 C2 u7 i* `* `; {
End if 2 G! W Q2 V* H- s; _+ m( ]
End Function
' \' _- S: Q7 C1 m" [/ t' T! l
0 a9 _4 h1 B7 G( c+ J: R7 ~'目录复制 ; u1 `% l [; J' L) {$ k8 c+ s8 e
Public Function CopyAFolder(SourceFolder,DestinationFolder) ) U O% h5 q6 e) A, F2 F- L; N
objFSO.CopyFolder SourceFolder,DestinationFolder
3 u( ^( m% G2 T0 f; X7 v8 ?/ UCopyAFolder = 1 C2 I4 k9 }2 Z5 j( C. r
CopyAFolder = -1
- v- C) `% h. \$ _6 BEnd Function " Z8 o9 j; j' b. h
) K% ]8 `& P$ j6 K* A/ Z, d
) r0 O9 A3 ^: e$ O: w x( a'目录进行移动 4 u$ Z* T T; m
Public Function MoveAFolder(SourcePath,DestinationPath)
' o# B1 C5 J! a5 ^7 T+ Z3 F; G" OIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
& }, m9 a8 i5 a0 z2 RobjFSO.MoveFolder SourcePath, DestinationPath Z% g" C* m* ^
MoveAFolder = 1 ! b- e* W: ~% _& f+ I7 H
Else 2 B$ C$ H! N R0 B9 i
MoveAFolder = -1 % F5 c5 N1 x4 ]3 e
End if
O- z, F/ i4 c. b1 @* G7 b yEnd Function ; r+ @8 e) C( |8 B
' a4 ~# s5 H0 I( ^) a$ m% L5 A'判断目录是否存在
5 d+ N; t. s# uPublic Function ReportFolderStatus(fldr) ! F J6 u( m) l( Q
Dim msg
% u* q1 ^7 p4 _+ Hmsg = -1
2 R" k2 V' v' W9 s. @8 iIf (objFSO.FolderExists(fldr)) Then . J6 T2 ^5 k8 n
msg = 1 8 |. R( i- o- P! A" } w
Else % P9 K {( l. D8 j% s$ G& ~
msg = -1 2 [% G2 z, z; U% [' O9 Q7 O7 D6 Y
End If ) Z* L& X9 g4 [! ^$ J* l9 Z5 y: x9 s
ReportFolderStatus = msg
; Z4 _; L D: E) _End Function ) k" b! L% P* G8 q/ t
4 e2 e- t; S2 H0 Z
'目录创建时信息 + A3 y, r# D( ^4 D0 {3 i
Public Function ShowFolderAccessInfo(FolderName,InfoType) 0 _/ a; f; Z$ C) \; t. F
'//功能:显示目录创建时信息
/ B0 ^, o* s3 ^$ i'//形参:目录名,信息类别 % H( N$ G' p% L8 q4 ~8 o
'// 1 -----创建时间
3 z% `" g% e: M: ?* ^'// 2 -----上次访问时间
# I# v% C5 q9 c& R8 \'// 3 -----上次修改时间 9 o& Z- @5 p" c/ R4 g
'// 4 -----目录路径 9 @7 r; r5 ^+ ^& y) j' r, i
'// 5 -----目录名称 " e; _" q9 i$ ?2 k
'// 6 -----目录类型 + x# o- ]7 }( p: `% P+ ]2 ^3 [
'// 7 -----目录大小
f# s" q M; `! @1 ~9 B'// 8 -----父目录
; L3 ]' J/ c, M. t: b'// 9 -----根目录 ' F$ e- n# N$ v& B5 V
Dim f, s 4 { P9 p6 g( x p; Y! r6 E' A
If ReportFolderStatus(FolderName) = 1 then 2 T* o$ D6 \8 k6 h& a
Set f = objFSO.GetFolder(FolderName) g6 p: J& p; U9 k2 @- r
select Case InfoType 9 j6 c; s) A. c/ S$ T
Case 1 s = f.Datecreated
. F) N" B1 @* OCase 2 s = f.DateLastAccessed 6 C8 T1 D) l7 ^
Case 3 s = f.DateLastModified ( L: @+ k1 K: ?" k' T4 O9 s6 T5 E
Case 4 s = f.Path + ?+ y3 v% n, b S3 L
Case 5 s = f.Name
% G( Z9 z; p' k0 dCase 6 s = f.Type
4 j: z# w$ w% v" ~, m5 b- ICase 7 s = f.Size
; J1 e2 x6 a! {8 O/ d0 m/ }Case 8 s = f.ParentFolder 1 A1 R6 |6 r0 V& y5 Y) ~; u
Case 9 s = f.RootFolder 8 h8 N! n0 W5 }, C
End select
) ]5 n1 p6 b" X3 f" q8 H& NShowFolderAccessInfo = s 6 A% Z) r) L2 r& a' u
ELse
: j! i2 r7 E9 ^% [! p" T. G! Y/ dShowFolderAccessInfo = -1 - H4 m- S. a& u! e
End if
* G" m+ f6 w4 E" t' BEnd Function
; h: m/ `% w6 Y) ?2 {- _/ |" N0 c$ b W
'遍历目录 + f' N9 I+ _1 f: p4 E7 b" [+ \2 g: o) G
Public Function DisplayLevelDepth(pathspec) # @$ E- U+ x8 ~* x% O+ L
Dim f, n ,Path ( d6 \2 f( y* M
Set f = objFSO.GetFolder(pathspec)
. i+ u+ S- V+ K& ZIf f.IsRootFolder Then $ c) a, o$ r0 T) c, |+ d9 }$ @
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
) F4 w, k- s/ Y: A# fElse
" v0 G3 Z5 u' n6 t6 uDo Until f.IsRootFolder 7 D4 j5 K+ G% {+ Z* C) _
Path = Path & f.Name &"<br>" + D2 Z4 [4 ]) w3 c* H
Set f = f.ParentFolder
+ j e& ]0 w3 d0 R0 ]" X8 |/ Nn = n + 1 ) }4 u8 [( e1 j8 L. v P
Loop ( w6 ^9 p3 R6 k; c
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
- x- d- L0 S' X" PEnd If 4 K; R! x$ N5 e2 H. h
End Function 1 y) H V3 W' C1 z
0 M9 X6 }7 o, m1 z'========磁盘操作========
' C! L( z. ?8 H; r4 v% Q'驱动器是否存在? / V5 G" I$ K2 u# k# f
Public Function ReportDriveStatus(drv)
* {* N7 I6 V# c: ?' d. L: V7 J2 iDim msg
_3 D0 B/ _% J& _& N, V2 Zmsg = -1 ' \: N8 S. \( s1 I- w& U! _6 Y+ w2 e
If objFSO.DriveExists(drv) Then ( l$ F3 c4 _1 J8 c
msg = 1 ( C; h( Y: {( H+ s7 f
Else
% B" g U; i! e" u8 }( x; wmsg = -1 ! `6 T* S4 Z0 q- G0 S( f/ ^6 i
End If & h4 z- u+ y: S3 M
ReportDriveStatus = msg ! O) O1 Z! X9 G( b. V% \
End Function # E# v1 f$ ~/ I0 N
7 z/ Z( [, v5 _* e4 K4 {; e; d% h
'可用的返回类型包括 FAT、NTFS 和 CDFS。
+ @+ A. i) w$ G: U4 e! kPublic Function ShowFileSystemType(drvspec)
7 H& D! l$ N' O$ B+ Y5 {3 x! KDim d
" z; ^5 x" m* Z: V+ i( I1 t ^# e9 YIf ReportDriveStatus(drvspec) = 1 Then
. t8 j3 |% I. j" aSet d = objFSO.GetDrive(drvspec) ( r# Q1 X( |' ^5 n$ C
ShowFileSystemType = d.FileSystem $ I4 F/ _2 ]6 w0 z6 v( x
ELse
! `8 |6 l0 m6 S3 {7 GShowFileSystemType = -1
) l$ ?3 R8 \9 Z6 ~: V' qEnd if
# O( L* @& V; N" l$ U0 xEnd Function
$ K9 l" I2 f6 j) K# EEnd Class # J" \' [) `3 T& n( _" q. h$ a" U* a
%> |
|