- 威望
- 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文件操作大全* F5 Q$ s+ A7 v5 X
<%
& x' p8 x* E3 d! I# w2 i2 |; C8 aClass Cls_FSO
! [: r, J/ g3 t) Y/ o4 ^Public objFSO
) o; M: E% D% JPrivate Sub Class_Initialize()
, J! Y% i8 a; V/ E2 u oSet objFSO = Server.CreateObject("Scripting.FileSystemObject") / |# _( @) [$ w" ^; L
End Sub - o. j1 E9 s; q3 I& E( ]
Private Sub class_terminate()
! Y0 Q9 q1 s9 c& K: X6 z( M5 GSet objFSO = Nothing
+ S* A- w/ n% [End Sub
- ~1 A; j1 G: c8 Q5 d
; b* S* H% s; P/ R3 `'=======文件操作========
1 p& [5 a o6 l% p. @* e$ I'取文件大小
& M9 \' j7 a' n; ]5 t3 DPublic Function GetFileSize(FileName) 6 V& g) z. f' o$ U
Dim f
# o" m) ~( h# w/ q$ U6 i, tIf ReportFileStatus(FileName) = 1 Then
" b- [* j% [$ I& T0 |# J8 WSet f = objFSO.Getfile(FileName)
) m& o- k) [; C1 D1 C, \4 nGetFileSize = f.Size / t- J& i- {2 f; w' i5 d/ n2 u
Else
9 ] r, h9 g* S5 \8 yGetFileSize = -1 . l) k+ R5 g. a% N; M8 k h
End if
. C/ m. U4 ]" ~5 M5 hEnd Function
W* v* r. D9 j$ |6 B0 J1 v3 w, m9 S! D/ o! O
'文件删除 ; ]$ f/ j- r- t/ z, A" z
Public Function deleteAFile(FileSpec) / d( F! u: c; H8 C7 j1 Q
If ReportFileStatus(FileSpec) = 1 Then % \; b' p% |5 p! s- ^+ }$ n
objFSO.deleteFile(FileSpec)
2 S: Z& O& h$ J4 E V% g2 \deleteAFile = 1
# Q! r3 P1 c) Y" R% N! W" `9 c$ {Else
) J, m/ T$ U adeleteAFile = -1
. W0 S0 z8 z) Z% wEnd if
0 {4 N) ]6 B1 eEnd Function
/ S, U; q5 A+ c7 z+ j3 E
% L. v. S7 A( b6 E2 Y4 K'显示文件列表 * y7 F( r" c3 f) p- Y% r3 t9 I
Public Function ShowFileList(FolderSpec) 8 B2 \) O6 F, x8 L: Y3 _: d5 N
Dim f, f1, fc, s
, F g7 r4 |5 k8 BIf ReportFolderStatus(FolderSpec) = 1 Then
% _' [6 k, u0 Q$ P3 L. d) o9 @# ?& nSet f = objFSO.GetFolder(FolderSpec) & R% a; j) |7 b( P- R# K
Set fc = f.Files
9 K* e; E2 b0 _6 o0 y0 pFor Each f1 in fc 4 I& y6 j- ]% M2 | a/ h8 v, o
s = s & f1.name
- e$ a" M: Q+ k2 ~/ C# r4 as = s & "|" + u% q( ~- n9 i
Next
% G0 V1 m6 M! y* kShowFileList = s
" h. G% G$ \5 P- G7 O8 j7 V9 K7 mElse
. M) f) P& i" Z) d" SShowFileList = -1 ( }) B4 M6 K6 R' ^
End if 6 t( p+ s l- y" x' {
End Function 0 y; ?+ f, R; E4 {1 H
# I6 Y% u6 S! `1 j0 W'文件复制 8 _5 C( D* J& y0 M! k
Public Function CopyAFile(SourceFile, DestinationFile) 9 {' `% u& D7 v' S2 k2 C# H& N
Dim MyFile + F! L; N3 f1 b
If ReportFileStatus(SourceFile) = 1 Then % x; C ]* R+ B! d
Set MyFile = objFSO.GetFile(SourceFile) & W: f4 V" q' ^! R3 z
MyFile.Copy (DestinationFile)
) g! o+ \! U, U' v( iCopyAFile = 1
6 g+ J8 h! ?7 D; x/ RElse 1 ~$ O% Z% L6 Q. @7 Q) V
CopyAFile = -1
3 g- |/ k3 C, ]/ H7 XEnd if - r$ X/ h* j9 A! b; _' s
End Function 6 i4 O5 K R! r9 L
0 N4 v# j- X$ M& _$ E
'文件移动
+ A2 V2 b% g9 o: rPublic Function MoveAFile(SourceFile,DestinationFile)
& Q/ a0 O1 `: L; OIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
: k* F: s. L' \" zobjFSO.MoveFile SourceFile,DestinationFileORPath $ E4 L0 M$ t& K) ~+ @( _& v
MoveAFile = 1
/ X* g& q1 c3 D: y3 |8 NElse 5 J( ^4 P/ A5 v l5 x
MoveAFile = -1 5 U# k: l) S3 T4 W0 Q4 ?
End if
1 l3 a" V7 D' s* CEnd Function + N3 P9 I$ ^, s0 @
l5 o! f" w3 ?0 n" J+ Q7 ~' L
'文件是否存在? , `* ]9 }( r$ [8 `9 b7 a8 d
Public Function ReportFileStatus(FileName)
( h# a4 b- K/ y z5 r+ z$ DDim msg
2 c1 \, a4 O# Emsg = -1 " R7 K5 V) `- R& K2 w3 @- b
If (objFSO.FileExists(FileName)) Then
# }' u: T2 e4 @% ?msg = 1 8 M/ e3 B8 z) {+ c
Else
1 i v- _# F$ q% omsg = -1 $ o1 P. `! O2 G" n4 J2 H, q* V0 u
End If
! C9 z, O7 c' t. ?. y1 zReportFileStatus = msg $ A4 L- l" k0 v' v9 A
End Function
6 A {# B. n8 h3 _5 U) P0 k3 W* Y7 ~7 m. P- O
'文件创建日期 " e6 Y l' T/ i' {7 I* g
Public Function ShowDatecreated(FileSpec) & T0 H% v( q) R) J
Dim f
+ c2 s* D3 ]3 p+ XIf ReportFileStatus(FileSpec) = 1 Then w2 r9 C% `/ j- E) u
Set f = objFSO.GetFile(FileSpec) # `6 l: S! V! F5 P4 p* m
ShowDatecreated = f.Datecreated
7 E c/ q( i0 l/ G7 X( TElse
: s" _ c( R# TShowDatecreated = -1 & R) |; ?$ i: z0 Z% G) T$ h* J
End if
& H! ~, h# s$ Y' K) XEnd Function ! [2 c- X$ z2 v0 T( A% y! E4 e* M
A7 J. b( V/ H' Y3 i
'文件属性
, Y6 k7 L; s7 u9 M) p/ Z" S9 t& v1 NPublic Function GetAttributes(FileName) 7 X; Z1 x6 y6 S; w; C) Y" J7 ]
Dim f ; Y9 G$ Z2 @8 ]% ]8 n
Dim strFileAttributes
7 |# d4 c4 n% P/ pIf ReportFileStatus(FileName) = 1 Then ! |8 ]$ L, ~3 w5 h" I
Set f = objFSO.GetFile(FileName) % M0 N7 W6 l! K* Z2 _ m6 `
select Case f.attributes
: s9 r! A+ H. R' a% U; J+ hCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
4 [$ b' g$ [7 \3 c! ^Case 1 strFileAttributes = "只读文件。可读写。 " 3 W& D5 i( i) H2 _; o: J6 ^0 F2 s
Case 2 strFileAttributes = "隐藏文件。可读写。 " - x3 T3 { D! ~
Case 4 strFileAttributes = "系统文件。可读写。 " ) M1 d( l( n d4 J
Case 16 strFileAttributes = "文件夹或目录。只读。 "
2 T# L& n+ c/ N# Q5 DCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " " M7 o6 C; i3 J7 j' B
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " 2 i9 |3 f- M9 G( J" b
Case 2048 strFileAttributes = " 压缩文件。只读。" 4 S" j' q3 P& A2 A: L
End select f0 a; a2 o4 C' D I \
GetAttributes = strFileAttributes 0 M) y* r7 _* N" z- y
Else
5 R4 c3 m5 t0 p$ MGetAttributes = -1
; @# j' D3 L* P) U9 F" ZEnd if # B5 N! J) ^& Z; j/ L* ?
End Function
$ I) V+ H% P5 W( s8 T9 }% {8 G2 _( ?. c- S; H. S6 Y
'最后一次访问/最后一次修改时间 6 |/ f* M3 j# Z& W. A
Public Function ShowFileAccessInfo(FileName,InfoType)
& l8 P9 i5 H8 `4 G, ^6 w! U'//功能:显示文件创建时信息
7 b3 d& q) R3 \% k7 ['//形参:文件名,信息类别 4 |9 v1 G( o# s7 ]( d
'// 1 -----创建时间
3 \+ q# i* [4 ~# R* ?'// 2 -----上次访问时间
0 g9 I7 `' k0 u7 x5 d1 |" j'// 3 -----上次修改时间 $ J# C( d- j0 F3 {* L
'// 4 -----文件路径
( t J8 u# p3 Y$ L& ~/ l'// 5 -----文件名称
1 l f3 f$ r* r9 H0 d# e7 J'// 6 -----文件类型
- c+ w8 l; `, }'// 7 -----文件大小 " T% o& u' e. H1 T1 \5 I. M
'// 8 -----父目录 7 [; ]9 P1 b, {' d/ E$ O$ Y. Q0 x
'// 9 -----根目录 8 ^+ ?5 c% Y% |& n! p* M" e
Dim f, s ! G* J0 q' j' u: P( ?
If ReportFileStatus(FileName) = 1 then
; R1 r& L* J4 Z5 C1 h( T4 GSet f = objFSO.GetFile(FileName) 5 i% R( P; Q) q! l2 k/ V( T9 r( z3 U
select Case InfoType A8 i! z1 C; Q2 u, i
Case 1 s = f.Datecreated
9 Q* }& s: m( h0 mCase 2 s = f.DateLastAccessed
( F! z: Z# C" ZCase 3 s = f.DateLastModified
0 n. R2 [( @. [Case 4 s = f.Path . l7 p/ f0 y+ N; X8 E+ H
Case 5 s = f.Name , B, X0 r! c4 J% q
Case 6 s = f.Type
' e( k0 ^" t. e- M6 a3 wCase 7 s = f.Size & b4 u- V3 O& H8 o2 b) s
Case 8 s = f.ParentFolder
1 b: V E1 A$ N T, [Case 9 s = f.RootFolder
- `. t9 }% s1 a& W n( y4 MEnd select 3 r6 [/ W0 `3 I6 Z* h
ShowFileAccessInfo = s
1 T9 a: W2 d/ GELse 7 q1 Q4 Z; ~# E! U0 {
ShowFileAccessInfo = -1 1 t& E$ k5 v! z! x. x' L
End if
. N3 w" |& z8 i. O& c# h/ ^8 uEnd Function 4 A$ Z& \' k# ^% r' W5 u! ~ E9 [
& l( r, }" v# ]7 T" W6 `2 c
'写文本文件
8 V3 [3 ~" z V2 h5 p: TPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 7 O6 A9 M: y# ?, L) d: b- z0 V
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
: e. m* O: b) |' H0 ]Dim f, m ; H- r0 y5 M7 y6 i
select Case WriteORAppendType & x0 Z+ t% X# A5 a' k6 K3 J1 q
Case 1: '文件进行写操作 3 N0 ^3 E7 ~' r8 {& r
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
% @: D& f# c. g: Z$ ~+ A! mf.Write TextStr
5 D( v4 ~( U8 u$ b8 mf.Close
( W) w i R/ E# p, oIf ReportFileStatus(FileName) = 1 then
) G& K. o- ~+ \ R* z: v1 k" o! nWriteTxtFile = 1
2 _ g9 W- \0 ?Else
' @5 P& X) T6 z* H/ uWriteTxtFile = -1
( z' n4 t2 Y, K5 @End if " K8 t/ S4 ~! ?, [4 z N* D
Case 2: '文件末尾进行写操作 ; d# j2 N$ O S0 s- g# o
If ReportFileStatus(FileName) = 1 then
+ Q9 {5 Z, e B$ C" E) nSet f = objFSO.OpenTextFile(FileName, ForAppending) ) u$ }6 E) C8 f8 p3 K
f.Write TextStr
* X: d( g$ K# |3 @# of.Close
8 l9 k% a+ O6 S e* wWriteTxtFile = 1 8 T: b4 L1 y4 v. G; |1 u8 U% I
Else 5 ~& ?) W( v/ g& s6 c: Y
WriteTxtFile = -1
3 `- H, e+ U' G- Z8 WEnd if $ i: s0 d& L3 _7 P" s* M
End select
$ H9 R& Q6 d$ ]8 ~ zEnd Function
+ Z: K) ^/ m+ ?6 V( C6 | C2 S- @! F0 u3 ]' |: I. E
'读文本文件 % U/ H: R( Z; m$ a: L/ E6 E
Public Function ReadTxtFile(FileName)
5 ?3 u0 z9 H4 O# ~Const ForReading = 1, ForWriting = 2 2 l3 |4 O7 C9 [# j) ~: u: e
Dim f, m
) J. |+ W- h+ s- I; VIf ReportFileStatus(FileName) = 1 then
8 k% c7 k; U5 \Set f = objFSO.OpenTextFile(FileName, ForReading)
. P4 ^" q8 L' A; D" m4 R4 em = f.ReadLine
3 k1 F( i3 e% Y: V7 kReadTxtFile = m & U9 C1 p! G2 G* o2 L9 g( M3 a6 ^: @
f.Close 9 o8 \, \$ N0 v+ K, H
Else ' T% @# W; f6 w: [7 }
ReadTxtFile = -1 8 ]) E, q' \2 l* p0 l
End if
4 T {. Y$ o! GEnd Function 0 |8 o# `- `. ^# ]( ?
0 ~3 o8 U% C( p% S6 I+ h/ Y1 l
'建立文本文件
m9 v9 T) s4 F& P. I' y( U# @6 F, {: {3 ]& o
'=======目录操作========
& @+ t" h0 C3 ^' E: d3 ]'取目录大小 - }1 d6 X* N5 z# ]" T2 V& A
Public Function GetFolderSize(FolderName)
L* C1 _* F7 t$ G4 U0 hDim f ! m* }" e: s h4 s) R, h( N, t
If ReportFolderStatus(FolderName) = 1 Then ; D5 o! X' i& o" O3 o3 i+ R
Set f = objFSO.GetFolder(FolderName) % d% V9 H- Q3 C6 r# ?, C
GetFolderSize = f.Size ) Y' ?1 Q, Z: r
Else
9 @2 E8 v2 o( s5 h' ^/ lGetFolderSize = -1 : Q; b5 [7 D% F0 C1 o. r" ?
End if
$ u6 U& @" G* w; X: IEnd Function
& R( X$ d- L2 w7 R' r" G1 m' W1 H) o2 S& F) S+ e
'创建的文件夹 : H0 e3 D2 @" Q( y2 \ _
Public Function createFolderDemo(FolderName) }/ ]: ?. e+ D* @- L2 k
Dim f
2 G& ?' ]( ?* gIf ReportFolderStatus(Folderspec) = 1 Then
0 H3 l. \5 ]7 W8 K9 QcreateFolderDemo = -1 4 C9 `. l) _$ `
Else
) p6 W' p' O& Y: I! i& R" q) _Set f = objFSO.createFolder(FolderName)
0 J0 x S. l, e( RcreateFolderDemo = 1
# M6 r4 d* C$ OEnd if + R) `- u. u" {
End Function ( X- R" |$ H% C% K+ G6 A$ {
" a s A+ N: k3 ?6 ^* T'目录删除
. n% C1 J3 E7 Y4 |Public Function deleteAFolder(Folderspec)
9 A& N3 A$ {; j1 |, ]Response.write Folderspec
: c( l1 [: `1 B/ `$ x7 eIf ReportFolderStatus(Folderspec) = 1 Then
4 {4 P" K! L# o) t! l0 X' Z8 q9 O DobjFSO.deleteFolder (Folderspec)
6 w: S" ^! C( h% U6 v$ T$ H0 d' `# EdeleteAFolder = 1 # ?2 j9 a, l7 @1 u# D' ]' o
Else x& d9 S9 x Z7 g5 i8 z9 \! j+ h3 U+ E
deleteAFolder = -1 9 c! d6 W1 [( G2 y# x0 K
End if ) Y& S$ w4 h2 N- \, O% o+ b
End Function
0 C9 I7 |* y0 l8 j) @( s
X# p8 k4 u, L! ~. y/ ]: I: t'显示目录列表 * p/ F# P: V0 ]! i4 _- b+ R" a
Public Function ShowFolderList(FolderSpec) 2 A2 h3 T5 [# M- Z. [/ c
Dim f, f1, fc, s
6 H# b3 v! V# W! mIf ReportFolderStatus(FolderSpec) = 1 Then 6 x. A1 b5 G, Z6 m* j- \
Set f = objFSO.GetFolder(FolderSpec)
' D. ^! U- f3 T4 KSet fc = f.SubFolders
; Q( D7 h, ^8 ]4 ?9 a1 f# m8 i I" LFor Each f1 in fc
: h7 y2 A% U: W" |' }s = s & f1.name ) S5 g ^) t4 Y( b3 D5 u
s = s & "|" k1 T- M K' j( `
Next
0 c3 s7 B4 l$ U, `" aShowFolderList = s
9 f& h! ^: t& Q2 D0 j4 X+ AElse
2 H9 L6 S1 b, Y" hShowFolderList = -1
2 @/ L w% Z; ^End if
0 f% W% i% k# a/ S, s" G$ H" ?End Function
# {& H8 l5 T1 P, k' P8 s6 R( T8 s, o }- m5 \
'目录复制 ( q5 j; C7 A0 b( s Q
Public Function CopyAFolder(SourceFolder,DestinationFolder)
, ^! h5 K6 G! |3 I7 }objFSO.CopyFolder SourceFolder,DestinationFolder
# [" d8 B2 Z: V: Y' d% TCopyAFolder = 1 " C2 [3 H" |; C/ o4 ]3 h) i, N
CopyAFolder = -1
6 y' S; Z" c$ l" o# L9 @# V3 KEnd Function 0 G5 O$ ~) f! u; s L
0 E0 w5 N; l5 y; v
+ Y& a$ b6 O* S8 F
'目录进行移动
+ G" F5 V% e; ?5 OPublic Function MoveAFolder(SourcePath,DestinationPath)
" L1 U6 J/ f, e3 Q! e; z1 IIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
* P! y( e! n' aobjFSO.MoveFolder SourcePath, DestinationPath ! C5 f, t5 X- O6 X0 }/ z: R) F
MoveAFolder = 1
( Z, M# D1 M# F% z4 e+ F6 H. VElse " j3 s# m. u9 o/ l ^
MoveAFolder = -1
3 b, u$ [2 @& JEnd if 0 w n7 w' j/ x% L
End Function ' n* D. n/ n( [3 k8 F% M) j
2 ]. c( q7 n0 {! I" ~( R
'判断目录是否存在
' n \( s8 g+ a! W5 Y5 k8 u% yPublic Function ReportFolderStatus(fldr) ) f: L1 t: n5 s1 s9 ~
Dim msg . w% x" C* w8 W4 H
msg = -1
# c5 f, l) k9 w* w) ZIf (objFSO.FolderExists(fldr)) Then ; I! l3 l D: ? H. P1 j2 k# N3 ^7 L
msg = 1
2 N. A: A5 L/ s' m* X; u7 `/ PElse 8 Y" ?! I* u/ k0 i
msg = -1
" ^+ i" z3 ^/ n0 I2 [End If
7 h y6 w# W4 fReportFolderStatus = msg
8 [% T3 f2 W- P5 |0 yEnd Function
. w: E5 w' g/ y: ]: M% d- Z/ T- N% u' u9 u0 m8 n
'目录创建时信息
: Y, D$ R8 |, m/ v BPublic Function ShowFolderAccessInfo(FolderName,InfoType) 1 e j8 f9 l4 @* G6 X" k+ c
'//功能:显示目录创建时信息 2 {' S+ G! _- [7 w" X" F* j
'//形参:目录名,信息类别
7 ^# Z0 N$ a. b: N! R: h'// 1 -----创建时间 m) z. U6 r$ L& {* Q5 r( k
'// 2 -----上次访问时间
+ H( L, L% G: C4 D% D'// 3 -----上次修改时间
/ d K% j$ l) ~& h. C'// 4 -----目录路径
- U( W) Y6 ~: N'// 5 -----目录名称 + k! |- V0 \ s; ?& A4 a
'// 6 -----目录类型
" S& V( m. v% t( _1 x'// 7 -----目录大小 P9 [0 a+ e- c) d
'// 8 -----父目录 : O. o2 h: o. R1 u2 f7 n
'// 9 -----根目录 6 W+ e# V; r1 I
Dim f, s 2 ?8 S9 M( i$ U# j" l$ u4 u* T0 I
If ReportFolderStatus(FolderName) = 1 then
8 W$ J/ C v" |- d0 Z: P2 USet f = objFSO.GetFolder(FolderName)
, P' B: G3 P1 _7 E- F$ Sselect Case InfoType + R. N% p/ N0 d# x
Case 1 s = f.Datecreated
" k; v9 W4 n" Y* W1 GCase 2 s = f.DateLastAccessed
* _: l- }) O; P( PCase 3 s = f.DateLastModified
( E' k7 j2 Z% Y. b+ x4 N( LCase 4 s = f.Path
" G, w- e9 W7 d) nCase 5 s = f.Name
: k$ k( |9 c* W; C2 B. iCase 6 s = f.Type : F+ `8 v. N0 ]. x* r- V! W
Case 7 s = f.Size
3 Q7 c. U; Z2 [1 z. o+ rCase 8 s = f.ParentFolder : ~/ N& L+ a0 w: o
Case 9 s = f.RootFolder
, I' J$ u- w7 Q# ]End select 2 @5 P, j+ E# Q- y/ V/ j) I
ShowFolderAccessInfo = s
! |! o+ e R0 E# r- y" AELse
3 I ?! [4 ^* E3 Z0 t# u5 ?0 XShowFolderAccessInfo = -1
4 A* x* a% g$ J& B/ h/ @5 I7 FEnd if
) t; E2 M D: d" KEnd Function
5 B0 K& {2 ~5 h$ Z+ a
, K$ X [% V5 M: g# x4 q'遍历目录
$ Y, A u- ~( v- TPublic Function DisplayLevelDepth(pathspec) # O4 l" s C) M& ^1 z: O. f7 w
Dim f, n ,Path . E" V5 s! z+ x3 [ M3 q
Set f = objFSO.GetFolder(pathspec) " q# M- W# o1 s0 T2 H& A$ r
If f.IsRootFolder Then
0 w0 J( n. ~" x6 N) BDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder . k7 N( A# v, v$ S2 t
Else 6 }/ @0 I$ b+ U
Do Until f.IsRootFolder . k0 L: e8 s- w$ r7 P E
Path = Path & f.Name &"<br>" 7 p5 X/ R2 \! `7 }/ y& {3 J) P5 ^
Set f = f.ParentFolder
/ z3 G( s9 r$ `/ E- ~* k4 X# Ln = n + 1
6 L! z5 N0 V! N/ \3 J9 iLoop # g+ G, c. g' p5 o
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
) \& P6 S; s2 F" Z/ ^End If
! I8 `8 a, `( V5 QEnd Function , A2 n, C" |% x; Y0 C3 n3 W
6 C# J( G" V6 s% h" L
'========磁盘操作========
- h# [, y( |! `+ z* K& c2 F% B: Q'驱动器是否存在?
) v# j$ z1 U) ^$ r# ZPublic Function ReportDriveStatus(drv)
3 q5 M# K% [7 e+ ADim msg ( {7 S% S, L" Z# o' m
msg = -1
9 [/ Q1 z/ P3 n: F" z# L jIf objFSO.DriveExists(drv) Then
" }, [$ C- G4 `% G1 |/ p+ v( jmsg = 1 . y7 B! f; ~( K- l7 A; b
Else % F" C4 @/ x4 C6 s* g( G* u, c
msg = -1
; [, Z$ x* j9 g5 R/ KEnd If 9 l7 ]( [% Q) {4 ]( \7 l0 ]
ReportDriveStatus = msg ' \3 z. o- K) Q: c7 K5 b
End Function 4 Z) |0 Y6 Q/ S* ?, n5 A/ F
) Q( S9 ?8 O8 m9 Q' ~& x; ^& r'可用的返回类型包括 FAT、NTFS 和 CDFS。 4 k# i, y$ |" M& m/ {9 F
Public Function ShowFileSystemType(drvspec)
1 t- a9 h7 p9 r. n: h# oDim d & w6 @1 X" L3 E3 {
If ReportDriveStatus(drvspec) = 1 Then
+ E( b" b2 ~( tSet d = objFSO.GetDrive(drvspec)
8 [3 ]$ o* h/ g% C: q# HShowFileSystemType = d.FileSystem 0 B3 e- D+ A L* U8 ~
ELse $ g3 G9 ^$ Z% A4 g" m# { r
ShowFileSystemType = -1 , v) ~+ P$ S/ w# E2 l2 v% d
End if * L) J) \; I. p, I" ?
End Function # Z& W1 L0 z9 c' G- l
End Class
& F [' v3 U! \%> |
|