【高州情】高州人深圳站

标题: ASP文件操作大全 [打印本页]

作者: Longe    时间: 2011-8-17 12:38:09     标题: ASP文件操作大全

ASP文件操作大全" b' `9 D1 Q6 d: U* |9 {
<%
; i- ?' y2 Y3 TClass Cls_FSO ! k; W. P5 b; g' s/ |, A
Public objFSO . f. \) z8 E- N* d! \
Private Sub Class_Initialize()
2 w: O9 I) e& O, [8 N3 QSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
5 _6 t: f1 K: z3 V# kEnd Sub / r, ?0 f7 }; x6 L7 n+ {" f
Private Sub class_terminate()
, \/ u, w) N" {5 H+ r/ F; [Set objFSO = Nothing 3 X1 ~. V* z9 a( X% I
End Sub
, z9 ~  M& c4 A0 w9 M$ Z
& M7 _0 @: G; }2 Z7 ]' h1 N! R'=======文件操作========
8 K: ?) f! A0 Q, o* v9 C1 ?6 L, |'取文件大小 4 z/ F9 O7 [3 p8 M
Public Function GetFileSize(FileName) 0 Z" \+ r" d4 }+ D# N
Dim f 6 J" n; a( A; y# P2 Y+ T
If ReportFileStatus(FileName) = 1 Then 5 {5 a3 C6 b) X4 @3 T$ L+ t
Set f = objFSO.Getfile(FileName) " N/ w; \& t+ E& Y# s& X! d, H
GetFileSize = f.Size
1 H$ s2 k5 B) w  k: k! xElse % S( Z$ T  z2 h# t* D
GetFileSize = -1 : r/ b/ z4 g4 L; _7 N
End if + j( A! s8 ?7 A/ O9 Z1 u
End Function ) i  G/ D9 M# \7 j$ @5 a0 j' V0 T

; c$ c% j( m! W4 h+ h  \'文件删除 / {- O. g9 b. v# L+ K2 B  y
Public Function deleteAFile(FileSpec)
/ Q/ C! K. N; _+ [6 m0 T0 l3 pIf ReportFileStatus(FileSpec) = 1 Then
7 y" }6 O$ |) ]objFSO.deleteFile(FileSpec)
1 B1 y1 @8 g+ SdeleteAFile = 1
4 f- Z& R9 `, P* A' S  x1 O. O& jElse 8 B! C: B6 D2 q  w
deleteAFile = -1 7 G; \8 h. P. ?2 a  ~$ p
End if
7 {% E, h1 w3 ]End Function 5 c5 D6 R  b' L. M; ?

+ J+ ~! A' D7 O) t% O3 J4 A'显示文件列表 % S% q8 i  a  O6 u0 B! @1 N3 \
Public Function ShowFileList(FolderSpec)
7 n1 I7 t/ A! S  nDim f, f1, fc, s
. f" d) G  D; C/ L: CIf ReportFolderStatus(FolderSpec) = 1 Then
" D2 y2 d* Q1 A' K! z: L9 ESet f = objFSO.GetFolder(FolderSpec)
! l2 c; c, m, `Set fc = f.Files $ q; a" }  n) Y# J6 R
For Each f1 in fc , U) c$ J6 G$ U  C* N
s = s & f1.name
* k1 }5 T3 s6 z7 \1 c7 ws = s & "|" # n$ A6 q# K7 _4 X) N* U9 l
Next 9 R/ r$ C' _% S0 R/ \' B8 s2 o' d& M2 N
ShowFileList = s - p. `5 }" J$ {/ u" R% U1 l
Else
* o: @2 i* `! u! Q, z0 ]  @ShowFileList = -1 . Y5 l9 y, G$ l' D6 b% C
End if 2 y0 h8 s/ U9 F; k" f1 n7 ^
End Function
. Q5 J! \8 {9 ^
" x# g+ Z- N1 i0 A5 n& `'文件复制
4 Y1 O" a, w  [/ c3 HPublic Function CopyAFile(SourceFile, DestinationFile)
* p$ i, L2 D! ~$ }2 oDim MyFile , F3 P; d* d  f; M. K
If ReportFileStatus(SourceFile) = 1 Then 0 U0 w+ [7 ~. M( S
Set MyFile = objFSO.GetFile(SourceFile) * ^! b2 G" C8 G' ]
MyFile.Copy (DestinationFile)   n' r/ k, X/ w9 `: A3 T+ ]
CopyAFile = 1
( l5 r/ j% F- bElse 6 X2 B% [* W- \5 E. j
CopyAFile = -1
( r/ [  m3 R# x; \8 UEnd if
# m( n' S+ g6 _$ jEnd Function
. r! j5 I) L+ i; u2 u1 f8 ]& A3 G3 ?
'文件移动 1 L4 t1 D' l3 X4 Y7 M8 T
Public Function MoveAFile(SourceFile,DestinationFile) ( ^0 a6 D" ?8 n$ `+ ]% x5 J0 Z
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then " ~" k) R% {+ F  u; {- x
objFSO.MoveFile SourceFile,DestinationFileORPath
% O0 q4 a! U; J) g2 v2 }9 H- h2 gMoveAFile = 1
- U7 v6 i  v* C/ U# Q* n. iElse
1 M$ o& Q( T2 P  mMoveAFile = -1
/ N! l2 W. Z* w8 N0 `% D5 MEnd if
0 w* Z0 t- }" d( q7 z- YEnd Function . j2 A0 ?4 X% `8 j; U3 f& h, q
2 F, v  L/ ^, _' z3 M7 T
'文件是否存在? 3 {- A0 v; t7 U, u: I- `& M
Public Function ReportFileStatus(FileName)
" d; p* E1 ^$ hDim msg   D  ]7 C& f+ \/ `! H8 H
msg = -1
# P4 f( F& ~6 ~' b  O" r6 ^! rIf (objFSO.FileExists(FileName)) Then
: O4 E. z1 M1 A( }msg = 1
/ H! B3 [7 v, C, s( j" E" Z- a( Y$ GElse " d6 E/ u; j! M* I% E& i
msg = -1
5 a) c. Q4 \7 E3 S5 R# R# DEnd If 2 S+ S5 _& r* S6 {' x
ReportFileStatus = msg
5 Q& T! I9 G# V! \$ [End Function
+ z, C9 x& S2 ~2 i
* E+ q$ ?4 b0 [7 Y, s'文件创建日期 - H2 A& K* T# M0 m
Public Function ShowDatecreated(FileSpec) 4 b2 y% y- }3 J( B
Dim f 7 d3 r! b  f9 ]+ p1 R3 A6 C5 A
If ReportFileStatus(FileSpec) = 1 Then $ i; ~6 Q" q3 B4 J; O% |7 V
Set f = objFSO.GetFile(FileSpec) & T$ M; ]* t$ \+ C: y; M, Y
ShowDatecreated = f.Datecreated
7 X9 m3 _$ I9 OElse 6 Q* D/ G8 I# ~3 w: l- o
ShowDatecreated = -1
5 c8 ?) Q0 L) b; L" ^1 k" wEnd if
* p: Q' H2 b+ r! K! G. bEnd Function 7 G6 B4 l6 u% u; J! u* M% G

0 n, E. y" K& C/ j'文件属性 3 e2 m6 S* N( f( {# V
Public Function GetAttributes(FileName) / k6 Z/ c7 \% U
Dim f ; `+ G) G6 e. c
Dim strFileAttributes 0 g, R( U) K/ [2 R
If ReportFileStatus(FileName) = 1 Then ) r7 C8 F- A: u: q
Set f = objFSO.GetFile(FileName) # i# T% K& }2 Y( H; l3 k
select Case f.attributes
3 M% \  D; D3 x  s$ N3 KCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
/ Q0 x6 j7 ^/ J9 h" h4 X9 tCase 1 strFileAttributes = "只读文件。可读写。 "
/ K6 k( R6 T7 v4 uCase 2 strFileAttributes = "隐藏文件。可读写。 "
; Z( x( P, I' u8 b+ k! [6 pCase 4 strFileAttributes = "系统文件。可读写。 "
% d) a/ M" H5 ^Case 16 strFileAttributes = "文件夹或目录。只读。 " % z! \6 a0 j. |
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
- ]( a3 n$ t  d3 P4 {; E  U' D2 ZCase 1024 strFileAttributes = "链接或快捷方式。只读。 " 1 k6 R1 Y" H- J  {0 H: a
Case 2048 strFileAttributes = " 压缩文件。只读。" , E; p9 F$ c" A  w
End select
8 ~; B, G! x7 ~GetAttributes = strFileAttributes
/ b2 o5 p0 m& n% SElse
- \" L2 V; ?0 x0 HGetAttributes = -1 " A' ?& V! r% c! u+ D6 h) |
End if
7 w% x  Z5 s7 I- C& m7 ~End Function
) c8 N- B/ L( ^# y  c0 |" t* Q7 T! e
'最后一次访问/最后一次修改时间
* C" X; \& N* w; Q4 {: Z7 l* j+ G3 _Public Function ShowFileAccessInfo(FileName,InfoType) " B" F, n/ R$ u7 \. e+ q$ j
'//功能:显示文件创建时信息
' B. u) t3 s, {' l' M* e'//形参:文件名,信息类别
. g9 P$ P. x. n4 y. N, D: ?'// 1 -----创建时间 8 j2 m: m6 ]. M+ T( \
'// 2 -----上次访问时间
4 {- T! J7 y, d* o4 ^7 c( P; ['// 3 -----上次修改时间
0 c$ n+ J: ^. e'// 4 -----文件路径
& }; ]9 Y- {/ B8 D9 U# C1 P'// 5 -----文件名称 ' [& ^2 L0 ?3 D' m
'// 6 -----文件类型 2 c* |# V% C- [  s/ p& |
'// 7 -----文件大小 7 m; T0 m/ C  {
'// 8 -----父目录 6 n# x( @/ a+ x# f2 X' N
'// 9 -----根目录
- Q& s  W! i& H( BDim f, s
/ f" v4 L( H: ~: g4 Z: KIf ReportFileStatus(FileName) = 1 then
1 M3 n. {: t1 f& J2 RSet f = objFSO.GetFile(FileName) . U/ U8 o8 @4 |! t' |/ L, Z3 \
select Case InfoType 1 |1 k( R% t: j: E" c/ r4 \
Case 1 s = f.Datecreated 9 U$ S1 s& O, a$ H
Case 2 s = f.DateLastAccessed : l9 h0 {; k( y4 W
Case 3 s = f.DateLastModified
" w4 E7 e/ g* G$ e: K+ g6 B2 GCase 4 s = f.Path
# ^, ~7 q5 D* H3 k* mCase 5 s = f.Name
. r' u7 Z% j9 V0 X+ |. v& N  v& X1 JCase 6 s = f.Type
+ p- Y! s# t2 T- M$ m1 g; WCase 7 s = f.Size 9 b8 ~. L, s9 d3 j/ l; r. K
Case 8 s = f.ParentFolder
. C9 `0 J0 p% Y4 Z* y) \% F, K9 \8 ^2 cCase 9 s = f.RootFolder
/ t$ \$ S0 N9 Q8 E2 x8 dEnd select 7 @6 P% `. G3 u/ a& B
ShowFileAccessInfo = s . Z# V* s" L. v
ELse
# g. a; s/ w" y' V( P/ lShowFileAccessInfo = -1
( t. d" E& h6 L: ]( w+ QEnd if
9 ?/ V1 Y7 ?. |+ ~. P9 b: xEnd Function
# z- e0 {- L1 j+ k9 B9 H2 r- C, ~8 U8 a
'写文本文件 # d( W. S' L9 D& A5 C, h- M
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) * {8 f; l3 z4 ~. s
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 $ V2 ]+ {; t( l# Z$ u; {
Dim f, m
7 G+ L' _7 i8 S( Cselect Case WriteORAppendType
# Q6 W% F+ V$ n. G0 E! m0 J/ JCase 1: '文件进行写操作 # l. N8 H. t2 [: t3 Y! ^+ e- h" F$ W
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
9 }. u. _) A# h, e/ Z+ uf.Write TextStr
* n/ u9 P0 C7 c1 Kf.Close + p% [# D. X0 t) ~% ^+ u
If ReportFileStatus(FileName) = 1 then / P' `5 D( Q* g: t! y- ~1 n
WriteTxtFile = 1
; G! O) U" i, g/ N3 a, ~Else 5 R- A9 U9 N# `! y
WriteTxtFile = -1
( @/ J" W0 }& h/ q4 QEnd if . @9 E( P4 ^6 d1 l* I; \3 s1 v" V
Case 2: '文件末尾进行写操作
# l# T# v) |7 i% Q* iIf ReportFileStatus(FileName) = 1 then $ Q# \4 A# g5 Y6 P# d0 u
Set f = objFSO.OpenTextFile(FileName, ForAppending) 2 }& s6 L; M: A4 v
f.Write TextStr 8 t: t- l, R6 H4 c1 |
f.Close
5 A% R! T: Z' J2 n4 CWriteTxtFile = 1
3 ]% W5 `1 Z6 g$ D" E! J( `: EElse
1 g" q7 o/ c1 A$ _" sWriteTxtFile = -1 . i4 ]9 Y: o: X6 I) n& ]
End if
, ?1 y; B) n; j5 t, D5 S9 j# LEnd select - d0 ~9 n: X* i
End Function
4 p8 I8 N4 S; d! a6 L( t) d1 b* v$ Z% U. y+ u
'读文本文件 4 f( o- S' m4 c8 W7 K: r. V* Y
Public Function ReadTxtFile(FileName) $ d* u- Q3 w+ H- w2 X* t2 c1 @8 h
Const ForReading = 1, ForWriting = 2
% a$ M0 K) v/ a; P/ a8 r3 Q* D5 |; YDim f, m 0 o  f) A! V# J! ~$ T6 e
If ReportFileStatus(FileName) = 1 then
) }, A- M2 K/ J, tSet f = objFSO.OpenTextFile(FileName, ForReading)
  v, H. P5 p$ |! ~6 ]( Y: m; A: _m = f.ReadLine
* s" d3 o' }3 I$ NReadTxtFile = m # N7 l- a8 A* @( K! S6 Z( h
f.Close
$ A( j9 L6 Z, }6 {. GElse
% j  V/ W. d$ L7 nReadTxtFile = -1
9 w* [+ S) Z9 u5 }! h9 R- vEnd if
  M6 A# |; w0 x! n2 t& z- W3 ?( FEnd Function
) _0 U- R3 L, T- k4 t- x& z8 ~8 i& T# a4 R. m) C( \
'建立文本文件 & k! f8 J1 ]! ~! C, X. ~  |

5 ~+ O7 ?; d% g9 m$ M+ q'=======目录操作========
5 G, [4 k6 G: M7 `, g0 b; [6 S'取目录大小
: Y. V/ ?$ ]. vPublic Function GetFolderSize(FolderName)
0 m% [8 [' @- }Dim f / K0 k" R. c; B: i/ h( O+ Z
If ReportFolderStatus(FolderName) = 1 Then , U4 g  b4 z! E: e3 ]( T; P+ ^
Set f = objFSO.GetFolder(FolderName)
: P( S7 k4 R/ ~( e3 wGetFolderSize = f.Size + a+ B7 a  D- Q- W
Else 2 `* y4 l8 U: W- f4 v
GetFolderSize = -1
7 s1 e( o' G1 `7 K) DEnd if
% `3 W) H! \7 r- IEnd Function $ K+ U- f, \9 m6 ~1 N! k

! F# j0 O" N3 A3 Y. K'创建的文件夹
! m. B, h2 m; H5 gPublic Function createFolderDemo(FolderName) 1 o& q* }) i3 b) C
Dim f
+ M. d$ E) r# e* S% Y: _- TIf ReportFolderStatus(Folderspec) = 1 Then . h' O/ y* S1 E
createFolderDemo = -1 - ]+ n: L/ q" J( H& A6 `
Else 8 @3 V! u( l4 z4 a( Y
Set f = objFSO.createFolder(FolderName)
6 n! n: x! m8 IcreateFolderDemo = 1
) K- Y( S* t! y, K1 e3 |1 AEnd if
* t* [5 S$ S3 v$ Q$ G+ q. _3 ^End Function
2 E" V2 U1 M. h& m0 e
3 H, O4 x/ M* Y0 c; a4 s, q) ?5 M; c'目录删除 ( Y8 ?5 D2 j# n- [
Public Function deleteAFolder(Folderspec)   g; L6 h, J+ I  p# ]4 P' q
Response.write Folderspec ) |. r1 w& y- v1 o  b' v
If ReportFolderStatus(Folderspec) = 1 Then
' ~5 M9 \' B8 n- @6 S0 zobjFSO.deleteFolder (Folderspec) % t! r5 }9 W8 [* H9 u" Y  `7 y& ]
deleteAFolder = 1 9 H  x& k1 Q# P" X( H
Else 7 ]8 A& Y( N3 ~
deleteAFolder = -1
4 g! T$ B' G" w, c6 GEnd if . |3 @6 V- z7 _" n5 `
End Function 9 Z/ Y, S( v" G4 b) `
4 t) }) Y: v7 b, \) ]: u6 l
'显示目录列表
0 f( Z2 ]4 u, d4 y+ F, H0 cPublic Function ShowFolderList(FolderSpec)
) @+ q: y. I# s0 `Dim f, f1, fc, s
- \+ W2 f& d  ^" W& ~4 `If ReportFolderStatus(FolderSpec) = 1 Then
% ^% Z% ^0 @/ }6 i" S+ K: f5 jSet f = objFSO.GetFolder(FolderSpec)
# d6 o8 r3 K! n# qSet fc = f.SubFolders
6 u* `8 r" Z6 kFor Each f1 in fc
, i2 ?# D  O; G& z$ n" T" r3 J1 Fs = s & f1.name * d2 I) y/ J  C1 k6 Z) T
s = s & "|" $ w+ t9 s/ [, P3 H. T/ l
Next 0 `2 }8 ]) Y. M6 t( E5 \
ShowFolderList = s
0 X/ T7 A9 L" J# x4 ~Else
% J6 V: A1 u' N* _' Y% p, PShowFolderList = -1
1 x; r# P5 u5 v6 X/ vEnd if ) N4 H8 J* d+ {' Z* A, ^
End Function 7 s; n- h+ a$ S. z4 a( b- b/ r

" K' c) E! {4 ^( |. A2 T9 B: d2 P! C'目录复制
9 ?6 t% I0 n4 r. V" {. HPublic Function CopyAFolder(SourceFolder,DestinationFolder) " X( h- t! g# ~, v8 L: D" E: c- h
objFSO.CopyFolder SourceFolder,DestinationFolder
9 E# A" `5 u. G+ S$ c/ p( F6 T6 L5 `CopyAFolder = 1 9 H. n  Y  }1 n$ h" X% ]$ ]- O' z
CopyAFolder = -1   @3 }1 _  W+ D* N3 k3 J% S
End Function
+ N0 F. Y, [$ F* d' {0 a
7 a/ m$ S! Z% [+ C; p; F3 e3 n* W, G& t: N7 ^$ r2 p
'目录进行移动
" {" V6 L" W1 I+ Z# `, bPublic Function MoveAFolder(SourcePath,DestinationPath) 5 r, U  P9 R, f" [+ @3 s# D" L- R6 }5 u
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
6 f: n- x7 e8 O/ j6 R- L4 OobjFSO.MoveFolder SourcePath, DestinationPath
% K4 d+ d. d+ `' P8 f2 oMoveAFolder = 1
4 u; A5 b' Z. r0 qElse
/ a0 g; t' x( L1 E4 Z5 OMoveAFolder = -1 - i& ^0 v1 s/ u
End if
, n" E  f$ ]8 U" D' `( iEnd Function
) s+ e* e4 P) W: O# h7 M4 {3 V. f# P
'判断目录是否存在
8 X* X7 x  d& T# {5 A$ h! KPublic Function ReportFolderStatus(fldr) 4 y) J7 b' D2 E! V( p
Dim msg ( z4 }& `* j, J+ H8 A
msg = -1
; {; b( s+ S0 X, W! cIf (objFSO.FolderExists(fldr)) Then ' ^3 o  [& B. I& Z1 H
msg = 1 ) H: ]$ S7 V2 `9 v# k. P9 l- I
Else - q8 U+ \5 G- {" D% ?
msg = -1 3 Q0 L5 L% K* d" r
End If 9 v; K; J$ O, h# [
ReportFolderStatus = msg 2 c2 \0 G+ S( F
End Function
% C+ ~% C; t1 N4 e# w8 n1 e6 ^7 g( ^1 ]0 }- @7 T; I
'目录创建时信息
$ k7 o! X( I; s0 J9 YPublic Function ShowFolderAccessInfo(FolderName,InfoType) ( s9 W- R! k4 M5 E% w& I4 t, D
'//功能:显示目录创建时信息
4 O/ q- S$ d! t7 |. g; g'//形参:目录名,信息类别 ; _) }% @' q" W" J
'// 1 -----创建时间 / @" P2 p, q4 a- [
'// 2 -----上次访问时间
8 _; L  U  \7 k* w/ o'// 3 -----上次修改时间 $ g& _& A" {' w% u
'// 4 -----目录路径 7 @# W/ I. ]+ m, \# }" ^, f/ M, `' N
'// 5 -----目录名称
( N: X# n" H8 a( x; ['// 6 -----目录类型 6 P; h4 `; L8 Q/ m$ J) Q" x- k
'// 7 -----目录大小
5 V1 ^: m) B9 P8 A4 K0 q( Q& m'// 8 -----父目录 % E9 r- H& x% P# Y
'// 9 -----根目录
4 b3 x5 Q5 i, [9 i! SDim f, s ! [! M: T: F# @) P
If ReportFolderStatus(FolderName) = 1 then
+ }5 a% P& G9 O4 E8 gSet f = objFSO.GetFolder(FolderName) 2 E0 i+ W  ]3 b- r1 r' m
select Case InfoType
  j% S7 {, ^7 _9 |Case 1 s = f.Datecreated / Q/ \' [. E8 q; ^) W
Case 2 s = f.DateLastAccessed
' c" |6 |6 g" P1 {% e3 n3 KCase 3 s = f.DateLastModified
. L& E4 \% {- }( P( s2 wCase 4 s = f.Path
3 S  F; \7 ]% z4 K6 C+ h5 z' G; TCase 5 s = f.Name
% y0 L" E; i& ^% I& wCase 6 s = f.Type % G4 J6 d! `, @) n0 L. y9 r
Case 7 s = f.Size - x. U4 H( [. R: G, k9 f
Case 8 s = f.ParentFolder $ q5 _! k, u7 R9 H
Case 9 s = f.RootFolder
  z) l7 _2 W' _6 O5 ?& A5 {2 ?- aEnd select , \! Q# c9 @& O' R+ l% a; j. k1 W9 a
ShowFolderAccessInfo = s + N6 U7 r9 r% L- ?! V! e+ A
ELse ( a) P4 ]+ v5 [( l
ShowFolderAccessInfo = -1 ) i  J9 |- J5 u( P1 I! A
End if 2 @% k  K# y: Z: T
End Function   h  i) g- f3 r0 Q  i' O0 ]) e
/ R) K# e2 |+ K
'遍历目录
( A% b" v* v" W0 j' l1 K) HPublic Function DisplayLevelDepth(pathspec) - o4 {8 O( R- b) G- d! a% h7 _
Dim f, n ,Path
& a/ ]1 E1 P$ o& B' j7 \2 i" hSet f = objFSO.GetFolder(pathspec)
' p* l! f1 \  @1 k: sIf f.IsRootFolder Then   L# O/ u. S1 R
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder % ~' d# `7 U3 ]( Q
Else
" U/ ]: Q/ ]* b! _6 l3 ~8 BDo Until f.IsRootFolder
, K$ V/ C% \( ?Path = Path & f.Name &"<br>" * F$ J  q  R" U  o* T
Set f = f.ParentFolder
# E8 k/ \5 M! [2 o5 N( nn = n + 1
) K( Q7 X+ n! W" R, a* {Loop 9 A6 [* F, k) B: Y
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
  E0 z1 `+ b7 n5 H! l0 MEnd If 5 i# s0 t+ l, @2 n+ j
End Function
! }0 [0 D* n) p1 t* j; L7 v) x) c$ R$ ?
'========磁盘操作======== 0 k. ^+ M* S" \7 B; }& R
'驱动器是否存在?
2 G5 I0 e, ~! MPublic Function ReportDriveStatus(drv) ( ?5 H) p& |; x, A8 |! D
Dim msg
: _* l' V4 z2 `0 Tmsg = -1 5 J" A9 t4 m7 G/ C* U! A' v: V0 {
If objFSO.DriveExists(drv) Then
) e+ k( w# R7 j3 @- k4 {0 u9 u! zmsg = 1
3 n& \- i$ @" |: i* qElse
4 l7 u5 t" W2 q" Tmsg = -1 5 {  H$ q- `5 r1 h. t
End If
* ^* G$ c6 }8 h: T4 Q$ Q" U2 vReportDriveStatus = msg
( t) O4 ~  B( hEnd Function
7 S% Q2 z+ R: h! T
# V$ T- b; T5 ?2 C( f2 D'可用的返回类型包括 FAT、NTFS 和 CDFS。 , K: k: F# W- x  H5 ^% h
Public Function ShowFileSystemType(drvspec)
# u7 z& o' C) G: U% JDim d , |1 h$ U8 A& t+ z
If ReportDriveStatus(drvspec) = 1 Then - V% Y  a3 w+ u  \
Set d = objFSO.GetDrive(drvspec) + @1 c2 o8 u6 c  Q- ^1 w
ShowFileSystemType = d.FileSystem - s. V4 y% a. M4 k
ELse 8 k+ G7 Q# p. j6 P0 p
ShowFileSystemType = -1
5 p7 V- z0 w* ^/ z$ l$ h9 C0 CEnd if
8 i" x3 F' F8 S* s: G8 F8 s1 t6 mEnd Function
3 D$ k4 Z- B6 x# `- @End Class + k; g" j+ P' \+ q7 I  M
%>




欢迎光临 【高州情】高州人深圳站 (https://0668qq.cn/) Powered by Discuz! X2