- 威望
- 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文件操作大全
% M8 o4 Q& K6 _% h5 U<%
6 I3 Q% E$ \7 d% c" b; ?+ `2 H" PClass Cls_FSO
4 e& X" L \8 l8 E& W+ e- hPublic objFSO 1 Y2 p. z! m$ x, O2 ^
Private Sub Class_Initialize() & F2 L; y1 n( d( s3 U. G/ ]/ a
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
S. K7 w) q: D# i( O, \End Sub
* J( X0 k" K, }* @Private Sub class_terminate() 7 T# X A/ G+ C/ [
Set objFSO = Nothing
- c; z) s* z: P+ J# k2 C' fEnd Sub
7 i5 b1 p o3 O- ?/ l6 U* p
4 N6 _8 m# v" d# ^'=======文件操作========
3 ]6 C8 k* q" s; r: P0 e+ _. E5 B9 [6 f& B'取文件大小
' o- Y2 Q' W/ Z6 h nPublic Function GetFileSize(FileName) # C6 n0 N6 U2 F0 C3 H
Dim f
8 v2 o. Z: {* C8 f, g# D) tIf ReportFileStatus(FileName) = 1 Then 1 y5 u: u( @ T, M& C
Set f = objFSO.Getfile(FileName)
: z% L6 ~/ w2 x, Y/ s9 [& b7 ^1 x& AGetFileSize = f.Size
( R L( O- ^# U8 e8 Z+ V& K8 OElse
$ G, ^6 z, N- C0 I6 \GetFileSize = -1 ) D3 r* c1 c, v. s/ `7 L2 m2 b
End if
- k7 w' A1 ^# PEnd Function
% ~! }1 b* i' d# v
5 U/ T, S$ `; \7 X* d'文件删除
; H# Y$ x, D4 ~* P( }+ C( kPublic Function deleteAFile(FileSpec) : Y( p) l8 z( s7 A1 i
If ReportFileStatus(FileSpec) = 1 Then 7 z5 \$ }# Q U$ x
objFSO.deleteFile(FileSpec)
3 N+ l i0 K; WdeleteAFile = 1 ( g, k( `% z/ Z" ]/ c: ]
Else
, e' c4 f% W0 IdeleteAFile = -1 " C' U& B, X9 ~7 P( Q
End if 8 Z# Z& V7 b9 x8 Z
End Function 1 e# f4 u M- c( R9 J
& m: n! b* T( x'显示文件列表 3 A1 e/ x8 Y' V% ^3 ?' I- ]
Public Function ShowFileList(FolderSpec) _3 R% a3 x1 I* z7 o
Dim f, f1, fc, s
6 |% ~9 [5 X2 J5 X! CIf ReportFolderStatus(FolderSpec) = 1 Then . V1 B$ j- r9 G& Z" f
Set f = objFSO.GetFolder(FolderSpec) & `- n, }) r6 }8 q0 @# u, r
Set fc = f.Files ( Y3 L! k. r" D I1 @, j' H" A
For Each f1 in fc
) _" r) l5 ^( ^6 x- q7 bs = s & f1.name
9 q* ]" P# k' O* s4 fs = s & "|"
8 D, o2 }. b6 _, m) _; h! t# [& LNext 0 Z5 N0 W/ F9 Q6 [
ShowFileList = s
# U, X9 k z# [% Y+ O, t. rElse
, j. r* Y( V1 }/ I x3 E2 K8 B* b2 uShowFileList = -1
/ Z9 y+ }" Y. {" X e2 P/ TEnd if
( R2 P* e* Q. m1 bEnd Function
" D3 N+ t" V1 m2 C( }) u, K$ z p( W( _# e4 @
'文件复制 " u0 d. N) S* |. D# F
Public Function CopyAFile(SourceFile, DestinationFile)
# c1 n& H$ {" C* bDim MyFile ; Y* g- d" @8 U; K
If ReportFileStatus(SourceFile) = 1 Then 0 {3 n9 F+ N5 i7 g9 Y* U8 H
Set MyFile = objFSO.GetFile(SourceFile) 1 a9 M" h5 K# e. @" s0 g/ h5 q3 c
MyFile.Copy (DestinationFile)
( l5 ]/ Z! X1 I X: O' g+ p7 bCopyAFile = 1 $ h: Q. ]5 C: X9 n+ M. u
Else ( X v) P2 f. P0 G, ~9 n
CopyAFile = -1
! L2 F- j/ J; C/ xEnd if / @, i, ?) u. r$ y
End Function & _# g9 C( ^* E* Q1 k" l
/ q( X; K* ?* X z# q'文件移动
1 e) \: U5 }0 BPublic Function MoveAFile(SourceFile,DestinationFile) 3 O, b0 }: m% D3 ? Q7 r t! b2 U0 X
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then ( \4 T& Z8 |6 h7 k( {: c& e. ?2 ?
objFSO.MoveFile SourceFile,DestinationFileORPath
" a9 a5 U9 S, JMoveAFile = 1 6 a; a) G- M* b+ {8 O" Q' Q
Else
6 {$ V2 D' I% `) V# ?5 a6 _MoveAFile = -1
+ L! V# z$ i8 G. v' C/ w9 i" z* t- rEnd if + W9 V- _( l/ i6 U
End Function
7 R1 J- t1 s1 o/ I+ Z
, M/ L0 J6 g. T- W4 J/ ?'文件是否存在?
' k( v6 g, k- w$ D1 |. `/ X; }Public Function ReportFileStatus(FileName) 6 @$ l, q2 {9 B+ m8 h
Dim msg * Y0 { U8 u1 [6 l" `% i
msg = -1 # I$ e0 V0 Z# x4 D
If (objFSO.FileExists(FileName)) Then - m0 ?& v8 e6 n3 K
msg = 1
* s% }6 I7 U- I* W* rElse , R. w" D: K z7 h. g
msg = -1
1 V. s4 z$ L; I- EEnd If
, Y: P$ n5 C2 }( \" |! LReportFileStatus = msg # f1 w" |7 i% _; h
End Function ' E1 b5 f, n, I; z2 \
5 G; k0 @& _& `0 ]
'文件创建日期 ; P+ F/ N D: [+ F6 y% U( |
Public Function ShowDatecreated(FileSpec)
) h! ?% z+ Q+ a/ H' r3 E* MDim f
( |, I2 Y V8 \, q# v; p; E+ cIf ReportFileStatus(FileSpec) = 1 Then
% [! ^0 m' ~- l9 ISet f = objFSO.GetFile(FileSpec) ! E8 m e% @$ E# s, c) z% X
ShowDatecreated = f.Datecreated
4 w! Z, ~& j6 qElse
! H. f2 b; }1 Z' w0 mShowDatecreated = -1
! x7 k! W$ ~# D0 p" J/ |End if
2 ^/ \" k. ], W. b' R1 i! tEnd Function
) H: r$ i1 n1 y' ~
6 V8 z+ _) B* U'文件属性 8 R6 G5 ?1 F" g" X' D1 U0 q2 {- Q
Public Function GetAttributes(FileName)
+ u7 }" k1 l YDim f 5 P2 H# g9 n: |; B1 c9 S6 Y
Dim strFileAttributes
' F# A& f0 V0 R& g% Y7 _If ReportFileStatus(FileName) = 1 Then . a1 Z) I* C: Z; o; r- Q7 u
Set f = objFSO.GetFile(FileName)
- R+ ]7 f& G6 X% A, Q. U9 Uselect Case f.attributes
7 C. D+ P. G A" j* n& e/ C7 w+ _) gCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
- |. n5 ~7 k9 [# Y/ R. PCase 1 strFileAttributes = "只读文件。可读写。 " * o1 }7 i- p; L
Case 2 strFileAttributes = "隐藏文件。可读写。 "
* t# }0 D6 I6 v2 x* ~Case 4 strFileAttributes = "系统文件。可读写。 " + K. _! u1 i2 G, a2 a
Case 16 strFileAttributes = "文件夹或目录。只读。 "
- ~ J( R5 A5 G# p0 yCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
\3 V. U6 P U4 y( zCase 1024 strFileAttributes = "链接或快捷方式。只读。 "
, K+ ?( i0 ?+ n, ]Case 2048 strFileAttributes = " 压缩文件。只读。"
( _, }. p8 _6 V& PEnd select
8 |" }9 Q) F9 \0 yGetAttributes = strFileAttributes
( M, K p( n9 C- ~& WElse $ p# s4 q; n3 L Y
GetAttributes = -1 6 S4 `* B" g8 a2 X
End if
/ }. e' s P, dEnd Function 5 F6 J2 {1 x7 ]2 Q4 J. i
- g$ e4 D+ U: U1 J2 Q& a' Y0 x'最后一次访问/最后一次修改时间 % v" a8 s( _$ ]0 @$ [6 X8 O
Public Function ShowFileAccessInfo(FileName,InfoType)
o$ N8 f- z, }3 e* A7 c'//功能:显示文件创建时信息
- _/ e4 c0 H( B# Q0 W9 M) U& J'//形参:文件名,信息类别 . S% P0 \8 n1 x. A5 l
'// 1 -----创建时间
( F8 m; O: @/ c'// 2 -----上次访问时间
, [/ o% G8 i- C- E8 ?'// 3 -----上次修改时间 % g) C7 B, f' V/ C7 t8 F, Z P0 o
'// 4 -----文件路径
' G2 f& r. L6 N! \! S'// 5 -----文件名称
) ?2 ]$ |5 r; r7 M8 w0 N) i'// 6 -----文件类型
( `: J/ |- E) t& I'// 7 -----文件大小
: u- z/ `( A9 c$ ^6 Y" e'// 8 -----父目录 v! p7 \3 N D9 Z9 p
'// 9 -----根目录
: K+ f) o, m8 kDim f, s ! o, u" j3 R- i; C2 q/ r2 I
If ReportFileStatus(FileName) = 1 then ( J: ]% d" V. R, ~7 I1 K
Set f = objFSO.GetFile(FileName)
. Q: w; b! u6 {select Case InfoType
9 @6 Z2 T' V$ ^: L. `! LCase 1 s = f.Datecreated / f$ ~: b, c) \# B( V
Case 2 s = f.DateLastAccessed
' p" l$ a9 M Z, B7 @' e3 _Case 3 s = f.DateLastModified
' g7 i. O/ C. g) n$ FCase 4 s = f.Path
8 g- J u4 K9 F1 T8 MCase 5 s = f.Name
. r, B, \. T; F _Case 6 s = f.Type
8 p2 l' J9 ~& W" f- ~% P1 L$ PCase 7 s = f.Size 4 q B: _" R* H3 M# B+ m: B: q: q
Case 8 s = f.ParentFolder
1 [1 x* u3 s; X7 v0 O+ Z3 `Case 9 s = f.RootFolder ; K+ k& c' L8 x! O l
End select 4 k `9 U* w( f8 L4 b" \
ShowFileAccessInfo = s 1 ^! R, P/ x2 Q4 j; U
ELse
2 y5 t6 Z0 }9 k: gShowFileAccessInfo = -1 9 E# u' t. k# F8 S/ i7 U$ \
End if
! y. d' y p3 fEnd Function 8 ?3 t/ p2 d P6 P+ [5 F+ q
, N- }1 g7 p) M \, {6 J- y3 G
'写文本文件 4 O% f" U' T& a3 ]
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 8 m. K8 Z& y1 b+ p; f" _
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 6 ~& X2 d" O) d' M2 T1 T2 [8 b7 t
Dim f, m ! }# D4 s0 a* z1 X0 s- X
select Case WriteORAppendType 3 W% U. i% I6 n: Q2 p% E- b& A
Case 1: '文件进行写操作
, |3 @ Q* h) z7 oSet f = objFSO.OpenTextFile(FileName, ForWriting, True)
* [- M# }( K+ _. E" @+ sf.Write TextStr
* g9 G9 V+ p: d* O% e! K4 Z" df.Close 0 D8 y. L" w: K* d
If ReportFileStatus(FileName) = 1 then ( c6 P. _ h7 q
WriteTxtFile = 1 2 y2 [$ s5 v1 }! H6 Y! @
Else
* a+ j' H/ E; F0 @9 Y1 ~7 ZWriteTxtFile = -1
1 A: u6 F2 l# v4 r. E! F3 nEnd if
3 y% ~& G# c3 J2 B( q, PCase 2: '文件末尾进行写操作 - r& x; z- f+ g, l/ \& o
If ReportFileStatus(FileName) = 1 then
) `; F4 C" [. u, l$ eSet f = objFSO.OpenTextFile(FileName, ForAppending) % `! M2 B( k6 {8 h& s+ E
f.Write TextStr
& w C- N u9 E! uf.Close 4 @( {* S# l" T+ A/ B! I. B& V
WriteTxtFile = 1 : J* e# a2 `" {, `) P# [
Else
! ^5 E# ^ A9 d" J: TWriteTxtFile = -1
# R% m" f7 M3 J& P' ]End if 9 |" d# g. M6 B; m; x/ l
End select
5 Y( Z9 h p9 X/ `' j5 _ ~End Function ( P% q+ E3 J6 k3 n3 `
9 Q0 S" H; c3 w8 ]" i8 L' U! a( {
'读文本文件
" n/ a m! g6 C: t3 BPublic Function ReadTxtFile(FileName)
3 B5 ]5 X0 O7 L& |Const ForReading = 1, ForWriting = 2
$ Q/ o0 P* r5 W$ k- MDim f, m
* `. |* g0 [# |2 S4 a! z" jIf ReportFileStatus(FileName) = 1 then
; ]* `% i E+ Q8 |# w& u9 p" l' fSet f = objFSO.OpenTextFile(FileName, ForReading) ! E$ k' \! Y' R" {$ [' O
m = f.ReadLine
/ C* u3 ^ ]5 j9 M9 g, AReadTxtFile = m
; x7 e: p7 C4 g( h- _f.Close
9 | Z t: f2 x& L( GElse
! P$ y, [- n$ ^6 v4 K8 A- I! QReadTxtFile = -1
. z6 X1 t8 j- P3 F! vEnd if 8 ~! U5 z( ]* w F- c8 N
End Function
, {- q+ D( \3 u" Y; F0 M5 E! ?* p8 a# _4 c
'建立文本文件
) [8 I, X Z1 M$ ]' t0 ^6 j7 P. U3 h" Y6 z6 a- t- J- }+ L6 L3 s& ^ ~0 i! K
'=======目录操作========
$ p# W, c' ]+ \* w0 \/ I) Y'取目录大小 9 V1 R9 _7 [ q1 `# l0 [6 t2 R
Public Function GetFolderSize(FolderName) " n& r6 H( |) E
Dim f 3 u5 P" Z; v" b7 Y- e
If ReportFolderStatus(FolderName) = 1 Then
, f, H7 q) W. i! m1 q' v) x% |; OSet f = objFSO.GetFolder(FolderName)
; G9 q ?+ I: C$ f6 a EGetFolderSize = f.Size 0 @' V3 f/ X, T6 _8 Y3 F) p3 \
Else
. Q2 t5 ?; N2 o* n# W9 H: iGetFolderSize = -1 & |- }' g: [' B! t4 ]8 _
End if
& L. t- O' L% F# PEnd Function
1 r$ F) s& `; v& y
: H: P1 c8 q: ~& B'创建的文件夹
$ f8 x3 u* b! p8 O, dPublic Function createFolderDemo(FolderName)
& @( ~; k- J0 P; |Dim f 4 L! Q! n0 s& U: a
If ReportFolderStatus(Folderspec) = 1 Then
( o5 l8 u- f8 {' UcreateFolderDemo = -1
) `8 o# ?# H- ?1 [: MElse
' I3 V0 m, y. z% l, ESet f = objFSO.createFolder(FolderName) 4 R( E" W9 }5 D7 g d0 L' O
createFolderDemo = 1
8 l& j4 M8 v; PEnd if
) q, _4 W8 e" p/ y1 O+ x4 a2 g& PEnd Function ; [2 x' U8 {4 A3 v7 V
C5 @! ^. u X6 I$ f6 F
'目录删除 9 U ^" q+ }% N# [% q' S
Public Function deleteAFolder(Folderspec) 2 p# U6 M5 L- F* t0 u7 _- l7 U3 I+ n# n
Response.write Folderspec
3 w( A3 x5 H1 X7 _If ReportFolderStatus(Folderspec) = 1 Then ! [" V: M( j$ l3 N6 v
objFSO.deleteFolder (Folderspec) ! s" b7 |1 p( W# k# m5 b, F
deleteAFolder = 1
2 ^& h& H4 e8 _/ Z) @) v! k+ FElse 4 t) p9 x: E; o) u
deleteAFolder = -1 6 e9 w4 a; {1 v4 z
End if , C; U: }" _- u2 y. n
End Function
4 J. Q, r/ A; [; i2 d3 q
) x- n- b1 w( P2 g/ B+ h8 e" S& r; |'显示目录列表
# {; f, W; y7 E% Z$ T9 aPublic Function ShowFolderList(FolderSpec) $ |& h7 m# Y. y
Dim f, f1, fc, s 5 q5 m9 l6 ` B7 f* v
If ReportFolderStatus(FolderSpec) = 1 Then
1 w& n" k/ n( O* h* wSet f = objFSO.GetFolder(FolderSpec) 9 m4 c; l1 _2 r- G1 G7 d
Set fc = f.SubFolders
9 R: f* E) \' A: _+ A9 p6 VFor Each f1 in fc
6 k8 Y2 t5 ^! Ks = s & f1.name
2 \% V% g2 J7 }" ps = s & "|"
1 Q ~ {% ^. X8 LNext
/ W4 d5 T2 d1 o# R- G6 C/ DShowFolderList = s
. a: b8 H5 D3 CElse 5 H8 z8 ?8 v) a" m( {
ShowFolderList = -1 8 ?% M( d; J9 v
End if # a0 D r5 g% n/ ?
End Function S% m( |/ K4 P3 w, A% D F, G
+ m2 G/ A- O$ z/ k
'目录复制
2 c1 ?" P: w! [$ m* C: ?4 j8 X jPublic Function CopyAFolder(SourceFolder,DestinationFolder)
9 g" m o- i! N9 z2 robjFSO.CopyFolder SourceFolder,DestinationFolder
0 B0 @& z- ], E1 `CopyAFolder = 1 % b3 k: @1 V& }! W1 y
CopyAFolder = -1
/ }6 l% K: r/ h. _. n) ^End Function & [/ c, G8 Y9 O8 Q6 v, d
4 k5 |/ b) i, o5 s- ]1 |( [2 ]: F+ r2 _+ D( A$ O
'目录进行移动
& {9 P% B$ ^+ U3 ^% BPublic Function MoveAFolder(SourcePath,DestinationPath) - p, t, B/ H9 D% x
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then 9 }' I/ i8 \; k; _5 D
objFSO.MoveFolder SourcePath, DestinationPath 0 d6 s7 C# H/ X
MoveAFolder = 1 * w! H4 @8 R$ ~
Else 9 @6 B5 z+ W Z& E8 E; q L g
MoveAFolder = -1 ; P9 g, e9 o! X% s1 }7 J$ F
End if . {3 m5 w" T: o
End Function
+ k n, |5 h5 r. p8 J. |' v
5 w9 H0 ?* O: s9 y'判断目录是否存在 4 q7 q: @/ W( U) B j6 }4 G4 o
Public Function ReportFolderStatus(fldr)
& Y. A& \: F0 U4 N7 b; l; DDim msg ! @) _4 L3 y; }" p' @; d* ~
msg = -1 : ^7 q( X% D6 c4 W( I4 \
If (objFSO.FolderExists(fldr)) Then / L. }4 |5 Y# y6 Q
msg = 1 7 G0 L, c" N# T
Else
: ?. P% q- v% N4 e2 w/ ~6 z Umsg = -1 : Y; y0 N7 V" d# u9 t) N
End If
/ Y' R" ~- }$ ? y$ J- v, aReportFolderStatus = msg 9 B+ ]9 k/ _; y r) v0 L0 X
End Function ' w0 h3 w1 Y8 G% P- \6 W
8 }! p, e. ?$ ]9 m
'目录创建时信息 - {1 j+ p7 X- `! w' N7 m
Public Function ShowFolderAccessInfo(FolderName,InfoType) 9 D7 J* |% Q- S: |, B5 t: ]4 Y
'//功能:显示目录创建时信息
( |& c/ @5 Z- J$ U% Z; w'//形参:目录名,信息类别
3 W# K. U8 ?9 C2 h J5 Z% ~1 a4 Y2 [; S- C'// 1 -----创建时间 8 m+ X9 @ s# W7 y$ H, E
'// 2 -----上次访问时间 . a w# k: [2 C1 |! F! R
'// 3 -----上次修改时间 8 x, ^1 R+ l; u
'// 4 -----目录路径 9 o0 K* U! Q* x; _
'// 5 -----目录名称
I a7 g+ b# l' f, r'// 6 -----目录类型
K9 G/ y0 k! L& n) d'// 7 -----目录大小
B4 u( e; c6 a# J'// 8 -----父目录
/ L6 y- ?' I: ~'// 9 -----根目录 ( H" p, }6 @9 s- D
Dim f, s
( V0 P" Y2 e: P0 bIf ReportFolderStatus(FolderName) = 1 then
( U$ f1 U1 t2 USet f = objFSO.GetFolder(FolderName)
" ?! K' Q% i8 s8 v" Sselect Case InfoType # W: O# P! d( y( @) r' K
Case 1 s = f.Datecreated
6 m3 J+ }: s0 n3 g# B3 Z6 ZCase 2 s = f.DateLastAccessed
/ y' P4 k$ F1 U! a/ J: w$ W/ x4 \Case 3 s = f.DateLastModified
( ?; M( N1 S; J, e& r2 Y" f _Case 4 s = f.Path
" ^9 f/ J$ B/ v" g M4 RCase 5 s = f.Name 8 Y, m3 `& j% Q
Case 6 s = f.Type
! s9 o/ j t3 M/ q6 h( G, tCase 7 s = f.Size ' @/ R7 b$ z0 B2 ~9 t# k
Case 8 s = f.ParentFolder
/ c) P$ H- S1 V6 f5 ~$ O1 l1 cCase 9 s = f.RootFolder & H1 n5 x/ b y
End select : v7 f/ {& i- h* {- I$ t
ShowFolderAccessInfo = s
& k4 K: ?; m3 d! I$ s2 y$ O, RELse * e' E! S2 ` h7 t
ShowFolderAccessInfo = -1
2 ]& H0 _4 i" b7 \) q/ c8 X/ M& rEnd if # _* B9 ~( U- @ [( A
End Function % k L: t) a2 ?- N) L9 ^+ i$ m
3 F- G2 [3 V9 Z1 F: ?7 r
'遍历目录 + i$ f+ c& B7 j+ y: a1 s' [
Public Function DisplayLevelDepth(pathspec)
' M. v6 P. Q: ^5 i. k0 g x) jDim f, n ,Path
8 i" E& d& N5 T% ]( r3 H7 l8 VSet f = objFSO.GetFolder(pathspec)
" ^% i1 M+ v) j$ k* G7 mIf f.IsRootFolder Then $ L8 j6 h4 u* I; R5 ]+ @/ x! i
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder 7 n9 N" j% X( t5 A' _* k# c
Else * D+ t D- f6 f4 j7 O
Do Until f.IsRootFolder
$ ^/ a5 G4 W6 m& o# a5 B' f0 YPath = Path & f.Name &"<br>" " a c" E8 w9 ^! [% K% A. |
Set f = f.ParentFolder
0 z9 |+ o% N! E5 fn = n + 1
4 w. ^" s6 x. U2 w/ d) @8 A. S% oLoop
! p I. X* P' ?1 K# W0 ZDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
% u s' q f, m$ @1 D( pEnd If
8 O1 b$ P8 G% M* cEnd Function
3 Q3 Z4 d w" B1 X& @# E* F; _4 D- [/ E
'========磁盘操作========
3 l. `- a9 U0 w$ P/ K& _/ R'驱动器是否存在?
( ~0 C9 A O1 q! L# Z7 w: S0 O& QPublic Function ReportDriveStatus(drv)
: M/ L& [- ]+ b) w6 ?! k% r/ _% CDim msg
! `# c% W K: M9 t$ ]msg = -1 . W* s" e Q( l$ L( {
If objFSO.DriveExists(drv) Then 3 i/ \& g. P& M: `2 J& E7 n7 ]
msg = 1 $ M' R+ w6 Q. F, o* l3 L
Else
* y" A* Y8 N: ~0 o. zmsg = -1
; t/ [* X3 u* ]; [* X4 n# J1 JEnd If 7 {& P6 Y) w- `, z5 x, V
ReportDriveStatus = msg ' O. a5 t4 P, m' N: |. L, x7 u
End Function t" D7 {2 y9 Y6 t3 b) i/ o) L
7 Q4 A& K7 o, K' T; C3 b5 v
'可用的返回类型包括 FAT、NTFS 和 CDFS。
, n+ l4 u7 P# ]: _* S1 Z0 OPublic Function ShowFileSystemType(drvspec)
0 p8 K5 J, Z }% u# ?, ~$ ~Dim d ( m5 P0 Y9 m x- z% t# Z
If ReportDriveStatus(drvspec) = 1 Then v, i- A( M# ]4 L4 ^+ E; V) }# Q8 J; f
Set d = objFSO.GetDrive(drvspec) r# a3 F5 B; C8 Y) U/ w3 Y/ c
ShowFileSystemType = d.FileSystem
U- q9 \$ x7 A, \ELse
+ ^! \; { f# n* A2 IShowFileSystemType = -1
+ b f6 j6 D: t/ i, {End if
+ F5 |, ?4 V% P* m8 Z7 mEnd Function
) e8 h: r. h1 xEnd Class ! v4 u/ Z$ T2 |/ G
%> |
|