- 威望
- 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文件操作大全& k3 s0 z0 N E- b8 M; S
<% 0 n% f; l: P, }. a; N( L
Class Cls_FSO + H, d9 ^& f& k* X) @
Public objFSO % R/ n: e# G2 n" P
Private Sub Class_Initialize()
1 g/ N1 M, w" eSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
P1 m+ U2 @) ` b/ ?End Sub
9 }. d6 A$ A9 }5 K, C4 y& o# m4 a+ qPrivate Sub class_terminate() ( S, [& w8 R _) i
Set objFSO = Nothing $ w+ z4 \ y. k' Y9 x; f
End Sub
% g2 M( ?* ^+ k
& f% v& G$ M' p. }! F* Y4 h'=======文件操作========
, Y. o( {! c' w5 h1 L'取文件大小 5 \& C6 G" T( N2 m( _
Public Function GetFileSize(FileName)
: ^2 C b% r( x' q7 D" TDim f " @% n) r( Z* f! `/ S t
If ReportFileStatus(FileName) = 1 Then
5 w# p+ P; {8 v0 J5 u* i3 g6 j& CSet f = objFSO.Getfile(FileName) 5 |0 j' C' `& A$ E) V/ a
GetFileSize = f.Size
, ` K( ^# m6 N# bElse
4 K- L9 W7 S2 Q, R( S- VGetFileSize = -1
* ~8 S9 i0 X- _) H/ _; k. sEnd if . q$ S5 }9 G* H" w
End Function + g3 |% K+ a. A5 [; c
6 S9 ~0 Y7 T1 h$ `- N
'文件删除
, m. ?) F A8 {) j6 U% \Public Function deleteAFile(FileSpec) 3 N& e( ?* N, p$ n) J
If ReportFileStatus(FileSpec) = 1 Then + c5 ?0 {0 `8 T2 z$ O a8 ~! N# ?
objFSO.deleteFile(FileSpec) c2 j3 m0 ~3 ^' ^; ?! D$ \
deleteAFile = 1 1 d1 q2 G3 J- m2 x/ A* \
Else
' C2 A# ^* ^" Y7 C9 C6 @deleteAFile = -1
* V9 M. ]1 |6 r& iEnd if 9 g+ h/ E' `8 i$ A' B3 _5 q$ b/ ^" i
End Function 6 d4 F" A# n9 ?( n* Y$ n
. m% V3 j4 E( [* [: S W( Q6 y
'显示文件列表 ( m* T1 r) J1 {1 l7 |7 w
Public Function ShowFileList(FolderSpec)
% S( |1 r3 _5 u& X# {Dim f, f1, fc, s 2 ?* j! T9 U/ e7 L5 z4 n
If ReportFolderStatus(FolderSpec) = 1 Then
" m9 z$ a0 B# t& \ jSet f = objFSO.GetFolder(FolderSpec) ! ]5 |: a5 |9 x- f) n: K, I$ F* Q+ P
Set fc = f.Files ! M9 A$ s r) E# ]: a r. q; a
For Each f1 in fc
' [ a9 \* s3 v! t2 js = s & f1.name * H0 g7 C! J$ B: a" D' G* H5 {
s = s & "|"
' \) [4 Y1 ~/ a6 d( Q9 x3 }3 _Next : R: Y6 T. B5 t9 P$ i, N1 o
ShowFileList = s
9 w# X' {0 ^/ _: i/ g8 WElse $ @& X' z& z' R" r1 K" h
ShowFileList = -1 : y8 Q1 H. o r$ g1 n3 y2 s( A+ \
End if
& H y& s- O2 {; d" h) d6 ZEnd Function & c u3 C; _+ d7 {. x' R
" R }& v# L4 R, a+ P1 T
'文件复制
/ _$ A2 Q+ ~; E- g }. ~/ dPublic Function CopyAFile(SourceFile, DestinationFile)
' k' O) y) K. L6 wDim MyFile
% _5 P4 |0 p' jIf ReportFileStatus(SourceFile) = 1 Then 9 }, [9 G8 x( w
Set MyFile = objFSO.GetFile(SourceFile) ) o: H2 h8 ~; J: }
MyFile.Copy (DestinationFile) / K4 r, \* d. A+ Q8 \$ V" M2 F
CopyAFile = 1
/ ]& a; e4 U; R# UElse + k, B4 w6 F! H! C
CopyAFile = -1 0 O2 h# w( Q: W# X7 D1 [: a
End if
% k3 C9 @8 r( L# \9 E) O# _End Function
7 H1 m6 i3 c& W9 b
7 F$ t0 B, ?) g6 o'文件移动 1 r0 ~% M# [) O, b1 F& L7 `+ T
Public Function MoveAFile(SourceFile,DestinationFile) 9 Y( R% q: h! z
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then 9 u& a/ q4 A8 E& N, y
objFSO.MoveFile SourceFile,DestinationFileORPath
- Z! W% y0 ?% a+ o! W8 p5 Q$ P+ IMoveAFile = 1 , H/ y: o) u' k/ I6 s4 g
Else % z9 D& K" Y* i. A/ O
MoveAFile = -1 - c7 q* W3 X* c* N6 g2 l# p
End if
" ]' }' q& W" Z$ q1 {- p/ z. kEnd Function
' t V: X1 p. X1 ^1 L0 b! f q2 L2 K8 V4 D- d
'文件是否存在?
3 o4 M f* D1 m0 `3 TPublic Function ReportFileStatus(FileName)
; f/ t" X' ]/ ]! t! cDim msg ( \) T1 X A) a7 Z, Q3 r+ {
msg = -1
' Z1 C9 @( K% v& v$ L0 M) @* dIf (objFSO.FileExists(FileName)) Then ; t5 X! o+ L3 K6 @% q
msg = 1 , Y7 ~% a f( p1 A
Else
/ _% n9 ~& \) K lmsg = -1 ( F6 s x, _% e
End If 6 z- o. b! t, G
ReportFileStatus = msg
4 W5 N2 q9 v/ P4 d8 CEnd Function / O2 c' |: W; w
* c/ H U* r: S6 z f
'文件创建日期
! {, ~1 M$ Y& q! V' e8 e9 pPublic Function ShowDatecreated(FileSpec) " f* `: `! {" I W8 ~- v
Dim f
; A1 e4 Q4 ?' y4 A2 f nIf ReportFileStatus(FileSpec) = 1 Then
- J7 }% {. W" ~) \/ f5 ?5 nSet f = objFSO.GetFile(FileSpec) ( @4 p2 e2 m* |# H& B
ShowDatecreated = f.Datecreated
x. t: A9 [, U/ ~% p7 n) |' W, OElse 3 z$ P7 t- M: g$ x+ D0 x; q0 B
ShowDatecreated = -1
" y( D# v+ ?& x7 IEnd if
' o0 e1 F8 H- }' ]9 eEnd Function * a% }3 B5 H; S1 N9 J$ Y6 {+ P
2 u, K1 Q& T' j3 J'文件属性
' @# w1 B0 V( t' u; i4 x8 s9 m: rPublic Function GetAttributes(FileName) 5 b5 J0 ?8 w! o8 I2 K, j9 p
Dim f / N% k/ m6 A% n$ T& m
Dim strFileAttributes
8 p! W: m3 [7 j4 EIf ReportFileStatus(FileName) = 1 Then + ?: }; X* V- I, U, w9 c4 u
Set f = objFSO.GetFile(FileName) * g% ?3 v- n) s! n# ^
select Case f.attributes
0 n2 m# |3 t$ F8 q6 |2 [9 h" dCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " 2 T1 x' ^0 U% ]6 ]
Case 1 strFileAttributes = "只读文件。可读写。 " 6 d0 _; i6 I* P; ?$ [
Case 2 strFileAttributes = "隐藏文件。可读写。 "
3 D% Q7 |% P2 O1 BCase 4 strFileAttributes = "系统文件。可读写。 " $ ]+ O* T: Y5 i5 i+ h1 R
Case 16 strFileAttributes = "文件夹或目录。只读。 " / p1 q9 D( f+ M3 ^1 u1 K5 f' Q
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " % f. B& J4 C( O! m5 S
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
" ~- M4 R m7 ?1 y* R0 MCase 2048 strFileAttributes = " 压缩文件。只读。" 3 b% F3 e" \. q6 w$ N. Y
End select 1 u" P' F0 h% O5 Y
GetAttributes = strFileAttributes
8 B& M! _% m0 _. B" GElse / Q% r9 E0 w6 \6 D( w
GetAttributes = -1
) c B, y3 S! H* F. }End if ) Z1 B* \+ i: W% U: @: n4 B
End Function 4 N: r6 R7 K) T5 X
) ]3 v2 C* m; R! A; l0 w'最后一次访问/最后一次修改时间
) S/ `) l E9 N' l* E: {Public Function ShowFileAccessInfo(FileName,InfoType)
' ^3 d- Y2 ] G( `3 e'//功能:显示文件创建时信息 6 j+ t& m- W# N5 Z0 }& z
'//形参:文件名,信息类别 ( v: E- u8 B0 ?- @# a8 k9 L) F; p$ ?
'// 1 -----创建时间
8 A+ N/ u! e( O% n! @'// 2 -----上次访问时间 7 C% p6 @' G8 ^! a/ i2 H$ q
'// 3 -----上次修改时间 , F/ B) }0 o d7 [
'// 4 -----文件路径 8 Q& i2 I4 ^# ?. E
'// 5 -----文件名称 ! r+ [/ E3 d* `$ D
'// 6 -----文件类型
0 G2 f' i0 m+ c' u! v1 p" B'// 7 -----文件大小
2 J$ [( @8 H* o, F( S* s'// 8 -----父目录
5 w: @' a @/ n' W, {, N8 R9 j'// 9 -----根目录
3 @4 z t& n* KDim f, s ) ~- B( C6 Q+ \' S' R" c @+ U5 s6 _
If ReportFileStatus(FileName) = 1 then
3 Y! H' h! @( P* Q; R0 E9 W) oSet f = objFSO.GetFile(FileName)
) i! | S( Q. S2 _6 Eselect Case InfoType
4 Q! v( B! j4 B& v0 LCase 1 s = f.Datecreated
7 k# v" @9 e. |5 [5 I' l6 wCase 2 s = f.DateLastAccessed
^% T4 }& ~2 q" o g/ E; ]8 w3 QCase 3 s = f.DateLastModified
" I6 S1 D8 h i4 n( ^Case 4 s = f.Path ( q/ q0 q* r- V! o ]
Case 5 s = f.Name ' }6 I; l$ S) f1 Q" {: O
Case 6 s = f.Type * p+ h) d0 i9 n! U, W2 Q% W
Case 7 s = f.Size
- a) O# y' j4 O- qCase 8 s = f.ParentFolder 2 t: `' I- @; N6 ~: w1 Y
Case 9 s = f.RootFolder
- F7 d3 t6 P4 ?End select
: [* [: \/ s* t K0 u- qShowFileAccessInfo = s . _( y7 G2 q$ B5 F) d! p
ELse 3 G6 r- s, s6 B* s& Z- I
ShowFileAccessInfo = -1
( L! P- Q, c$ pEnd if ' W) i/ {& F8 }; W7 s$ U' f
End Function
5 f, X& J- b: C) `+ s( T1 e9 Z3 n4 A+ ^
'写文本文件 + s) ~' h" _! D ]- c, N, P% |9 N; p
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
) X1 j+ ^4 }! _( GConst ForReading = 1, ForWriting = 2 , ForAppending = 8 9 T q* G4 b6 Z* f; s
Dim f, m ( k- B6 ], [8 t- H# u: T7 w9 q
select Case WriteORAppendType $ g5 x' A( v- T$ ?
Case 1: '文件进行写操作
$ l: H! V/ A5 t$ C5 `Set f = objFSO.OpenTextFile(FileName, ForWriting, True) % |% S# `, d" q: C& s4 o, P
f.Write TextStr
( N: ^% h) y5 u' Ff.Close ; i+ g6 b! c/ l2 \0 k
If ReportFileStatus(FileName) = 1 then % o* P% y- d+ [: y& U9 {; `9 n
WriteTxtFile = 1 5 |# k& J8 _7 W4 g) }4 c* t2 C. Q
Else
; D/ d6 G. b3 y$ nWriteTxtFile = -1
, T1 r' X2 L2 D: V6 wEnd if
" ]% I3 W. }; g. x" w6 ]/ G8 N$ xCase 2: '文件末尾进行写操作 6 V- w; w/ K2 x* Z Z; u
If ReportFileStatus(FileName) = 1 then
( G ?* d. m4 b. zSet f = objFSO.OpenTextFile(FileName, ForAppending)
" N' U- F. Z' U. Of.Write TextStr
" r2 K* L- W) N( jf.Close ) p& X( u, W1 C$ E, c
WriteTxtFile = 1
p7 |, P; q9 l6 M6 X: YElse 8 R: P' q, W( a0 l0 j
WriteTxtFile = -1 / \5 x( r5 H& D2 ]- U8 N& ]
End if % ]2 G+ p# w' t8 M( W) K$ p- h; d
End select 9 ^4 R) o- u2 I5 H7 y5 h, U
End Function
: v, n6 x! q! k: L$ |' n; i* I; m, _' X' T; v5 C) D" q
'读文本文件 8 f# ]9 {8 D8 u. \% j& ]
Public Function ReadTxtFile(FileName) % V ^& q j( K
Const ForReading = 1, ForWriting = 2
/ R7 u2 ^/ E' YDim f, m 2 x1 _5 j7 X1 ^
If ReportFileStatus(FileName) = 1 then 0 d1 l) s3 l- _! z8 `& y; {7 q8 x
Set f = objFSO.OpenTextFile(FileName, ForReading) c- W" D/ y F& S; K( y1 f
m = f.ReadLine % E, F, ]& T8 X( \; K# m$ {. I
ReadTxtFile = m
- Y, l7 }. p- c1 K& d+ P- bf.Close 6 K/ n1 \% V2 q' J' _3 s
Else 3 x- U y1 b4 k9 f# s
ReadTxtFile = -1 4 P' E% M' g$ P p' ]
End if
; Y! f% i: U+ UEnd Function 5 s1 g; K- L! q
+ e+ a- E$ r: C* J: w) K/ r7 V6 z9 E
'建立文本文件
9 k* m; _( N1 U" s% o" i9 \/ R Y2 B
'=======目录操作======== % T. A5 P/ v" u H) L
'取目录大小
$ z _$ z( X2 I; h; E3 d$ UPublic Function GetFolderSize(FolderName) ) W# [" i! f3 t
Dim f
- G8 n$ h$ r" u& F5 N/ G# G8 N- q9 i" |If ReportFolderStatus(FolderName) = 1 Then
* E$ \* H6 }% o3 s( K, C: ]5 f" L5 t7 ]Set f = objFSO.GetFolder(FolderName)
2 `! D( }1 O: J1 h2 mGetFolderSize = f.Size
6 I# c4 M. y H5 hElse 9 Q' P4 d% B# \ S
GetFolderSize = -1
" @# ~& Z+ I4 [# Z, BEnd if
E1 L$ z$ y6 v' R; ]$ kEnd Function - j1 u. y" @% e. Z& w
2 c- w! y- J/ O- N' Q: W
'创建的文件夹 / O0 x" n" y C# R }$ z! y
Public Function createFolderDemo(FolderName) ! {+ m/ `# c3 Q. h% U* A3 z, J
Dim f
( T/ b, C& B5 h! u1 w x6 c+ o' _If ReportFolderStatus(Folderspec) = 1 Then
5 F' I" U+ }: \$ X! ~ z: XcreateFolderDemo = -1
! d+ E* v5 h- W# y8 U3 f% vElse
b6 ^( B1 x6 n7 E" zSet f = objFSO.createFolder(FolderName)
V5 j1 t" ?) y' B& i) KcreateFolderDemo = 1
( e( s8 M3 K g( G0 t7 b6 WEnd if
k7 }! X1 m* G7 R# ? O+ DEnd Function
& D# r) ^# a. } s% E# x! i9 I) E* t6 I7 P' g' I
'目录删除
4 U+ G& |- `& A4 I6 g5 b4 i) cPublic Function deleteAFolder(Folderspec) ) H# ^2 @. D9 H+ ]
Response.write Folderspec
1 {0 j: B! {" R5 _9 y- @If ReportFolderStatus(Folderspec) = 1 Then 0 \4 Z2 u8 d3 D$ E. U4 i8 `
objFSO.deleteFolder (Folderspec) " l- q( t" s/ [! ~+ m P4 x
deleteAFolder = 1 ' Q F" G$ e5 J: M, p
Else 7 Y! C8 k' R7 n5 p a+ n8 {
deleteAFolder = -1 - s0 @( r* n: y; F8 I
End if
: k- b7 G8 a. Y" I& a$ pEnd Function : d" F3 R* }* l* m' E j5 a
% K% ~9 r9 B4 T# {" \; K'显示目录列表
! P5 h% C m/ d+ M8 JPublic Function ShowFolderList(FolderSpec) % u9 h+ a) I- \0 t) c
Dim f, f1, fc, s
7 k2 N5 {' w3 `6 u# C; ^* qIf ReportFolderStatus(FolderSpec) = 1 Then
' u9 Z( m2 _- e2 s1 ]8 s. O! f( `Set f = objFSO.GetFolder(FolderSpec) ) T# t, ^2 F6 C3 K4 k) t0 D& o
Set fc = f.SubFolders 3 F% U/ |1 C! j0 w1 _3 V
For Each f1 in fc ( Z, c1 p' @1 i3 E0 R
s = s & f1.name * s6 p5 V6 \0 t( G7 Q2 u+ m6 c
s = s & "|"
' H5 @. X" K% j8 xNext # L- H" ?. g" Q( b# g3 i
ShowFolderList = s 9 h; V5 G* b, z- ]
Else
0 E" ]9 D h$ z8 cShowFolderList = -1
) ]; f2 D O% v- c& g1 CEnd if
- E, O4 N9 `+ M. L, d1 O; X7 fEnd Function
x6 M3 A& r) D7 w: b0 x% Q3 U" W- }; v& u
'目录复制 6 W7 i: V g; k0 R* z. I% P0 H
Public Function CopyAFolder(SourceFolder,DestinationFolder)
; q1 ~% n' T6 U, t% VobjFSO.CopyFolder SourceFolder,DestinationFolder
$ ] t' Z& z3 r. T, c- B" c+ wCopyAFolder = 1 7 h# s; ?. |+ o+ J/ Y
CopyAFolder = -1 # C. g2 C! b4 Y7 C& i( m5 s, B* K
End Function
6 ]- `( ]9 P* u" @
# E( i/ h: a" x |6 s* B
+ D7 m3 y/ C# D. M'目录进行移动
/ P9 T$ A! P0 _: n' @Public Function MoveAFolder(SourcePath,DestinationPath) 0 m7 h, }2 W. { m, O7 t- ^
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
5 F8 Y, i2 V) o2 J; ?objFSO.MoveFolder SourcePath, DestinationPath
$ b+ s0 d! ]8 ^MoveAFolder = 1 - V6 ?2 b7 ]+ U) m0 `
Else ! z4 F/ G) U4 s% U2 h
MoveAFolder = -1
1 r0 j7 S* s u/ B' Z* VEnd if
+ i8 y5 v3 H; ^' }( p( ]End Function : V5 N/ v L' ^* G
, _/ R. c& d1 r# s1 k'判断目录是否存在 8 e; b, Y% S6 z7 L' v F* v
Public Function ReportFolderStatus(fldr)
; ~! @" a4 l% ]1 zDim msg
/ `& v. E8 _* a( g5 |/ bmsg = -1 ) T: g3 N0 |% [" u# _, q& f
If (objFSO.FolderExists(fldr)) Then
$ W- u2 L% O$ p- v$ t" Emsg = 1
5 I2 [& A( c1 N( NElse
* f5 H, e- _6 {, {5 \msg = -1 + B0 @. `( F; I7 v2 N
End If ; b1 y( |# {: D
ReportFolderStatus = msg
9 i. R; b+ }2 s7 ]8 U$ w) a4 x: nEnd Function
$ ^1 e$ i0 A# W5 h; R, Y1 x4 g$ j
'目录创建时信息
: S; K v4 Z; m# HPublic Function ShowFolderAccessInfo(FolderName,InfoType)
4 x; f2 `0 U) q3 Q v j'//功能:显示目录创建时信息 3 x3 O6 s# R7 n% q0 u7 J
'//形参:目录名,信息类别
2 M I/ Z6 H& J' \8 x! o# G. C'// 1 -----创建时间 : p8 X! f& e& E |+ }7 t6 F
'// 2 -----上次访问时间 8 Q2 _( B( [4 D, c/ c8 d
'// 3 -----上次修改时间
1 y" l. N [. x'// 4 -----目录路径 1 o& Z4 V2 M6 H$ V, Y
'// 5 -----目录名称 - Z1 f0 `+ W I1 K1 y( `
'// 6 -----目录类型
# q) U" _" n. L' B# r, l6 O: E'// 7 -----目录大小
0 T! P/ Y( w( ]# C6 l. J2 A'// 8 -----父目录
9 h$ v* X9 k* F* Z9 E% R7 l'// 9 -----根目录 6 k& K9 @2 k' F# e' G( j
Dim f, s J4 ^+ y4 V5 T+ u0 G. S1 D9 p
If ReportFolderStatus(FolderName) = 1 then ! K, ^0 F1 H0 r8 W6 {
Set f = objFSO.GetFolder(FolderName) ' \* F0 D( \4 ]- }! G/ U3 ~) p
select Case InfoType
+ b, R* ]( P. M' G" UCase 1 s = f.Datecreated
2 m, z9 U: T; n' Y. B# u" p/ h: [Case 2 s = f.DateLastAccessed
1 x5 b& l2 P' DCase 3 s = f.DateLastModified
3 F: o" P% ^2 |$ OCase 4 s = f.Path
: N y# o3 G. t8 r2 N- Y5 n9 xCase 5 s = f.Name 8 ^0 E7 H( U Z
Case 6 s = f.Type - [% l: ?- J; e9 c0 s% P; l
Case 7 s = f.Size - d! O5 ]* K* H# {& P
Case 8 s = f.ParentFolder
c3 K" p- [: s( z9 `, uCase 9 s = f.RootFolder 5 s. ^6 |4 I3 E5 K
End select + C5 n9 Z( w( T( W3 i
ShowFolderAccessInfo = s ; Y$ p) s2 I5 r6 Q' i' Y8 a
ELse / f4 P3 D/ H5 a$ a* \
ShowFolderAccessInfo = -1 - o* g% c& g6 b1 w/ L B1 Q6 z
End if 6 R m8 \4 r( o9 k
End Function 9 {! ?: ?1 c8 ~
( V4 t0 B6 _5 y7 d/ } v'遍历目录
6 |( P: x. M; p3 g' q0 RPublic Function DisplayLevelDepth(pathspec) 0 q* F/ P' F) }
Dim f, n ,Path 5 E. F8 V! c- F* {5 ~/ ^) f: j" `
Set f = objFSO.GetFolder(pathspec) 9 C# y. R4 |4 [
If f.IsRootFolder Then ^0 n$ n9 ]7 p- x$ c- `
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder : h2 s+ _/ @ W. n' ^/ `
Else ; o6 b5 k4 h6 v7 _7 x
Do Until f.IsRootFolder ~3 r: n0 l& e, l/ s7 Y5 ]
Path = Path & f.Name &"<br>" ( Q! H7 u1 q3 V" q) g
Set f = f.ParentFolder , V7 d' ]/ R+ u! X) j4 U. }) ]
n = n + 1 7 k: k% U% F% i1 `* h$ b4 h* N
Loop 4 G9 _ N. s0 q$ [
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path 4 x0 J7 [. \/ C4 l
End If
5 A" X+ `5 e) {# D, mEnd Function
) ?0 b! N0 C; V" n4 N% } y# z( |/ Q) Z7 \9 ` `7 H
'========磁盘操作======== $ q9 ^7 j# M% S0 K3 z) ^
'驱动器是否存在? * I: P) z/ [" T
Public Function ReportDriveStatus(drv) $ H0 D t6 U( u( U5 S3 a/ c
Dim msg + j# M4 U2 q: c( B- J
msg = -1
6 |4 N; \8 t" K* d) ~4 BIf objFSO.DriveExists(drv) Then 4 ]; S. I- Q! N# `- M
msg = 1 & S& o$ m; \7 Q$ W
Else , `; a4 y, P6 U$ Q/ B1 m
msg = -1
7 M# J7 Q: N3 k+ c9 BEnd If
* n( R3 ~. Y* d0 wReportDriveStatus = msg
# H. j' I, N( M5 qEnd Function
5 K; u2 _' H) E$ d) I& ?+ i% i- K5 V/ J. \; l
'可用的返回类型包括 FAT、NTFS 和 CDFS。 , o* d7 ^2 X/ B+ A4 m% r' \8 g$ k
Public Function ShowFileSystemType(drvspec) ! D' M ~5 f) m$ D3 Z: T
Dim d ; \" n8 F% [; @2 ~. o+ D# n( M
If ReportDriveStatus(drvspec) = 1 Then
" D* u5 M3 ^1 ^, dSet d = objFSO.GetDrive(drvspec)
- m- Y: h: K7 o2 N9 |$ DShowFileSystemType = d.FileSystem T8 H+ a1 [8 {6 |. a9 o8 Q
ELse
/ v, j6 `4 n4 S- Y; }* bShowFileSystemType = -1
$ Q# x) c6 X* Y1 a8 [4 i8 y: ~0 S2 LEnd if
o1 O3 l( z, FEnd Function
" g4 h- G3 a- \9 Q3 D& \ OEnd Class
$ @1 P( X4 g4 z/ f( q0 |%> |
|