【高州情】高州人深圳站
标题:
ASP文件操作大全
[打印本页]
作者:
Longe
时间:
2011-8-17 12:38:09
标题:
ASP文件操作大全
ASP文件操作大全
! i8 j; Y O2 o) m( c8 f0 H1 }" B/ G
<%
# s; u0 D6 C& Y& Q/ X# ^8 g& K5 }
Class Cls_FSO
) b+ K: D% Z; }6 b: n" `
Public objFSO
# p" \4 O# y# {
Private Sub Class_Initialize()
+ ?0 Y8 n# ~* |2 C# i
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
, S1 k# p9 K9 r( N: x+ U# p- v
End Sub
0 T5 d" m, i9 S c+ J
Private Sub class_terminate()
& P1 U: ~& u0 X5 Y
Set objFSO = Nothing
2 j1 i) B; W6 E. k, C7 g
End Sub
! j& V7 E3 ]: a$ v3 e
1 B3 c6 F& H; [ x& S
'=======文件操作========
' _& q% d6 K" k3 V
'取文件大小
6 [0 `2 ?. [' B* S" |) v1 x! L) f* }
Public Function GetFileSize(FileName)
# u9 U; q s/ x2 r. m
Dim f
# j; D, }8 G- D3 ]6 H1 x
If ReportFileStatus(FileName) = 1 Then
4 x* U- b K" \; }
Set f = objFSO.Getfile(FileName)
" n4 z* P# ?& n% z/ D, ]2 E x
GetFileSize = f.Size
; C! y1 L$ N& j- d- U) @
Else
$ X' W& h) f- t! C, b. p! e
GetFileSize = -1
# Q* @7 W/ |1 |
End if
4 A! {& k3 P7 [2 Z
End Function
0 q0 \- `5 [; z: n& Y
^* k! v4 {# ]1 p, W
'文件删除
" q9 p, o' v, E. L
Public Function deleteAFile(FileSpec)
% Q0 ~% \2 Y/ e0 r" ]
If ReportFileStatus(FileSpec) = 1 Then
7 F! n# t' x! a: d5 b2 ~! ^
objFSO.deleteFile(FileSpec)
* C- m4 p R `! Q& ~9 E6 z
deleteAFile = 1
% R1 i0 I7 h2 p$ s0 y G' `: V6 ?
Else
9 q7 U8 t5 S& _; m
deleteAFile = -1
& p3 S: w+ P) y' k/ c# i0 L2 m% u& n
End if
, M0 s- H9 l! x! S! L; b
End Function
2 }8 Y9 Z5 B8 U' V
$ S$ L7 P1 W' I- r6 Y8 U- E, P
'显示文件列表
$ g" H2 ~3 o0 h8 y( b
Public Function ShowFileList(FolderSpec)
6 E0 I3 V# y6 h0 V8 F* u- N. O
Dim f, f1, fc, s
0 x( X# D% |. a
If ReportFolderStatus(FolderSpec) = 1 Then
7 }) O. W) {8 d6 T# |! Z7 D
Set f = objFSO.GetFolder(FolderSpec)
3 o4 f8 `+ o. @) ?% a" u
Set fc = f.Files
: N: H7 x k. E. \
For Each f1 in fc
" b; X' @, W( ^
s = s & f1.name
6 ~9 V3 U l) E, \# w* S
s = s & "|"
1 r2 @; I& g; N. v) u
Next
& D, H0 E+ e2 ^+ ]7 N/ _
ShowFileList = s
Y7 Y1 `) q# ` f9 u; c
Else
! G8 p% z, n& }! D
ShowFileList = -1
( L1 n u8 a& b6 i
End if
3 b: X( Z1 V0 l) q* k! Q
End Function
7 M! J0 c4 k9 y$ `$ p; J- w; y
. }# q5 E! [( z G9 T
'文件复制
3 D, y) ]3 g9 q4 ?5 D: s
Public Function CopyAFile(SourceFile, DestinationFile)
- c' ?7 V; x7 F+ |
Dim MyFile
; E- Q7 c% j) J# O- x9 y0 C. y, T
If ReportFileStatus(SourceFile) = 1 Then
. N. i& [' U1 R+ f, k; {/ n" ~
Set MyFile = objFSO.GetFile(SourceFile)
0 w# G2 I- J3 q: A N. I
MyFile.Copy (DestinationFile)
8 [3 m b3 S _( \* j+ {& O
CopyAFile = 1
$ C3 z2 R2 ~" ^
Else
% g8 f( `& ]( G$ o; z
CopyAFile = -1
! m1 n4 c6 h. H+ P% p, \
End if
+ c: }) n- j" n) q' J$ I& {: S
End Function
1 z; X+ X5 T* W" {
* k4 n# E1 O' a9 M
'文件移动
, [, ]# u" e* G! h* j
Public Function MoveAFile(SourceFile,DestinationFile)
4 X0 ?- g( ]5 |$ {' N
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
( i; C4 w( B B7 A" n
objFSO.MoveFile SourceFile,DestinationFileORPath
* u# n1 E" U( Q
MoveAFile = 1
2 C {% }# A4 {& `* h& [+ _
Else
! i' F- Q' ]" G0 \% R
MoveAFile = -1
% B4 b. \8 @9 c1 S6 y& u
End if
: m0 j: c2 l d3 Q
End Function
$ H# J& t" p. {9 |. [: j
, g5 p- S7 M# Q1 a6 S' ]& d
'文件是否存在?
( s0 L0 C8 L0 D" I1 H
Public Function ReportFileStatus(FileName)
5 r4 A# |9 }: E( L
Dim msg
6 P+ U6 d$ ]# w7 \
msg = -1
0 b+ G. v9 _, \& e7 Q3 ~2 z6 r
If (objFSO.FileExists(FileName)) Then
9 u2 `7 |, M" ~; r( o
msg = 1
: [, v+ n5 O* f/ _0 r' s
Else
+ U5 F/ x* a! {/ b
msg = -1
* b: s" l2 Q( `# H- M
End If
8 q9 O: B) A6 N- y$ {. J' v& P
ReportFileStatus = msg
. D, l$ Y6 V n. ]4 q
End Function
9 O+ P& \; ~$ V$ o2 y. j
; l/ v8 N, Y/ v7 u
'文件创建日期
8 P9 I, h' E% p, `& ?
Public Function ShowDatecreated(FileSpec)
1 [% ]) i' c4 {2 S0 N7 C6 @7 Y
Dim f
# G& o8 F, d5 V6 L) B/ X
If ReportFileStatus(FileSpec) = 1 Then
4 T3 @2 Z! [" U! G
Set f = objFSO.GetFile(FileSpec)
6 O% d+ y, H0 h. a8 l
ShowDatecreated = f.Datecreated
. c4 W# L( r0 w
Else
5 }2 ~0 G, `5 B0 k3 w. |$ L
ShowDatecreated = -1
- i; {2 Q4 n0 u$ ~+ }7 G
End if
, g L! x" V0 u7 A% r2 z* d
End Function
/ C& u: w5 A8 v
" o& e1 [6 L, d' I( O+ }
'文件属性
4 }7 B: P0 U" O: ]* P
Public Function GetAttributes(FileName)
5 V# s! _/ M/ B8 l( w+ U
Dim f
% f2 W, m5 u8 r8 { {% r1 l. Y0 B# X, C) @- \
Dim strFileAttributes
$ h$ G* U; R5 M X% a$ H
If ReportFileStatus(FileName) = 1 Then
) u+ y8 l2 A0 P9 j# v
Set f = objFSO.GetFile(FileName)
7 b$ _1 \- e* @5 {3 e9 }6 |
select Case f.attributes
, l, M" A" q& F' R
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
+ Z6 Z0 r3 p3 B
Case 1 strFileAttributes = "只读文件。可读写。 "
# I" T2 F& |/ w3 ~ q8 Q
Case 2 strFileAttributes = "隐藏文件。可读写。 "
7 E: e8 q% }$ J( ]# ^6 U
Case 4 strFileAttributes = "系统文件。可读写。 "
4 b9 E4 I `" `1 u
Case 16 strFileAttributes = "文件夹或目录。只读。 "
6 N4 c& A+ Y! u( o
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
! [9 V; g, o2 i2 I: Q, E/ T
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
8 _( b Y, ?& w9 b
Case 2048 strFileAttributes = " 压缩文件。只读。"
! G5 X$ D$ s/ ~" r& @, E
End select
6 E1 G9 i3 N* {7 X: |1 c
GetAttributes = strFileAttributes
$ ^/ W& U5 [& O3 {, v/ m6 m9 Q0 C
Else
$ u M e. x+ R4 L5 M
GetAttributes = -1
" S! w: E9 M( f& ]$ D
End if
+ Y( l7 c6 g @( C1 D6 U/ [6 T
End Function
' m2 [: ~' U; e( I- n# u) c, ?& \& K
% M: ^, p* p j) I' O5 V
'最后一次访问/最后一次修改时间
8 j6 b/ e( D% S) C
Public Function ShowFileAccessInfo(FileName,InfoType)
. r3 p" J' F- B; s$ \
'//功能:显示文件创建时信息
6 _+ i. l) p' S, F# O# i: ]
'//形参:文件名,信息类别
5 [& P/ k, F, N6 t
'// 1 -----创建时间
* s' c; c) R3 `9 P. E
'// 2 -----上次访问时间
# }' q2 ^! ^* t$ f" B9 h
'// 3 -----上次修改时间
: I, i$ ]! m! h3 A+ E1 v% b$ ~9 f
'// 4 -----文件路径
8 k3 g8 t" |1 `( B
'// 5 -----文件名称
" c6 x, U4 [- Q, u- C' X7 w T
'// 6 -----文件类型
* o7 \" d& U* I# Y0 E
'// 7 -----文件大小
1 X- {$ e1 h2 M
'// 8 -----父目录
& f ?1 s; @/ J ]$ o6 ~
'// 9 -----根目录
* F* N" [' K3 g% Z% ?
Dim f, s
" Q8 W% r0 R) E* Q; o# w- \
If ReportFileStatus(FileName) = 1 then
3 W3 C, K5 k6 l+ v7 X
Set f = objFSO.GetFile(FileName)
$ Q4 D+ s. I; U7 ?
select Case InfoType
! ^% r1 A! g0 g
Case 1 s = f.Datecreated
" p8 U, M: V% | T- O$ n1 l" B
Case 2 s = f.DateLastAccessed
- a: E( }- O9 Q4 g, y
Case 3 s = f.DateLastModified
3 d. J5 U, Q4 l0 n. g
Case 4 s = f.Path
$ n( W& i5 s+ |# `
Case 5 s = f.Name
V- l, m1 r$ n' N9 k
Case 6 s = f.Type
; h" P' }" ]( x+ Y' s8 W
Case 7 s = f.Size
# P; x9 t* e+ ~# {% a, b) j
Case 8 s = f.ParentFolder
% L/ y" |3 o. n% _
Case 9 s = f.RootFolder
# H" O- g8 `0 H
End select
1 Y ^ e8 K0 k9 e; f
ShowFileAccessInfo = s
) M- R" C) C- Q/ X9 t
ELse
% E- A# b S) P* F/ i
ShowFileAccessInfo = -1
D6 I, _( B' g7 `- i! s
End if
) d) M% s$ I1 q
End Function
, w( M+ x; G E4 s8 I, D3 Y
; u; ~2 I: ^& q; @- F
'写文本文件
j) l4 |% q9 A7 Y9 T
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
7 h9 |, a( ]3 h. b) |
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
; c5 `6 M! s( g9 ?( z) n
Dim f, m
$ W' l6 h' ?0 U0 i: c! `7 q
select Case WriteORAppendType
; E& |$ I4 V% T# `
Case 1: '文件进行写操作
" I! B+ V- E% Q0 a
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
6 D! w2 F6 h1 S" Q' A: x/ U$ Y
f.Write TextStr
& O* P* Q" u4 [# a
f.Close
/ s0 @0 l0 e, I/ e" S3 h
If ReportFileStatus(FileName) = 1 then
" I* {! F+ p- L: Q. G( M5 _
WriteTxtFile = 1
: E) `" p2 U8 B. ], Y
Else
% m% L4 x, W, j9 Z
WriteTxtFile = -1
0 W: P5 c9 o7 N
End if
, B" F" L! V3 Y$ e: h- B
Case 2: '文件末尾进行写操作
* V4 S g: p6 k! G4 [
If ReportFileStatus(FileName) = 1 then
. X! }7 G0 ]5 g5 S( u, [
Set f = objFSO.OpenTextFile(FileName, ForAppending)
. L& |8 k8 }1 |$ b
f.Write TextStr
6 d! d* Y& H) y0 I
f.Close
" W: N9 @/ }5 j/ J
WriteTxtFile = 1
R( ^* [ ] I' ]: e/ F; J$ r L9 H
Else
0 f/ @" f% ]5 ~% ^
WriteTxtFile = -1
" Q0 z7 i0 H9 `: s/ T
End if
* c: I8 u1 N+ |8 i, k# W
End select
" b( @& y( C M9 L
End Function
8 K% \8 e# Y: Z8 o, E
9 K* M$ ~/ p$ U
'读文本文件
- x9 T7 t# q: l+ l
Public Function ReadTxtFile(FileName)
Y: m# i% U6 y% t: W
Const ForReading = 1, ForWriting = 2
A( S( {) m& ^5 M9 b; g) c- R
Dim f, m
' R! C! q! x) q- `4 d0 k
If ReportFileStatus(FileName) = 1 then
' f* {! K" B; q9 f* S0 e
Set f = objFSO.OpenTextFile(FileName, ForReading)
: j( g9 O6 f, v; l8 ? H( x8 Z
m = f.ReadLine
' v# A; E9 A4 X6 s% G v# `
ReadTxtFile = m
3 E) D$ J& Y7 I: Z. R- {
f.Close
1 t8 ^9 @! E7 x- m
Else
/ E1 t. ]7 U a/ f( ], \
ReadTxtFile = -1
% g' B' S% e/ M2 a5 U
End if
" m- S- k0 W3 s2 u+ B
End Function
- K( A% A+ m# S% U- U" G
$ a# B. D$ e0 j2 T
'建立文本文件
# d9 e9 N6 J4 r! B- }
# \8 L/ n/ p" w$ K) D5 H
'=======目录操作========
; v; z1 {1 m' c. }4 n
'取目录大小
* i0 G) w7 c4 x- t$ k+ }8 W) X
Public Function GetFolderSize(FolderName)
& g7 h! |& S+ M& g8 `* F- Y0 l
Dim f
4 _2 @/ Z$ X% B8 u( _
If ReportFolderStatus(FolderName) = 1 Then
0 ^+ A: t/ D0 M. V! T" _/ @
Set f = objFSO.GetFolder(FolderName)
v+ V) S" Q2 c
GetFolderSize = f.Size
: O9 }/ n. y- B* v
Else
4 o8 J) q% s0 t7 _8 x
GetFolderSize = -1
" g3 Z; z1 O. G6 H3 G4 o
End if
" d. V2 g/ q; J2 `. X
End Function
( u! |2 X; ~3 y& J
) Z: A% t8 _; N% c
'创建的文件夹
2 i# _; X9 k. K/ n* G3 \
Public Function createFolderDemo(FolderName)
2 o: n3 E/ P" T* b/ h: o9 q
Dim f
+ I3 P! [* X8 w2 \/ Y$ S
If ReportFolderStatus(Folderspec) = 1 Then
8 m9 E+ R4 r' P( t
createFolderDemo = -1
: Y& c3 I. n) D4 o0 H; v
Else
1 o; t% x/ U2 R% l& x) k
Set f = objFSO.createFolder(FolderName)
' m) B# I3 S, O4 w
createFolderDemo = 1
9 H- v# g) y4 L
End if
/ c/ D. x8 ?2 A( G" q/ ?
End Function
, V: e2 H y1 F) S9 q, l
. h' h9 k6 o0 [, [
'目录删除
1 f% K! X( Z+ y9 \
Public Function deleteAFolder(Folderspec)
' W( x% b4 T" q$ Y: U: }+ [3 n) ?
Response.write Folderspec
( }0 C. t* i1 {5 C5 f p
If ReportFolderStatus(Folderspec) = 1 Then
; d/ c8 B3 q4 t1 e* ^
objFSO.deleteFolder (Folderspec)
: y3 u0 j' r. F% g
deleteAFolder = 1
, \5 \4 P$ h; U9 B n& T, @# R
Else
0 z# g, b! D+ D* z! A
deleteAFolder = -1
+ M' A$ P/ r( b3 ] j
End if
) H, d" @% K0 S1 l& r6 I
End Function
1 G) ?% o% C+ q0 }4 Z
7 j; ]: i' L/ v/ @; T3 d
'显示目录列表
" _# G7 f$ W, I
Public Function ShowFolderList(FolderSpec)
* ~7 I9 Y& M/ ]3 [
Dim f, f1, fc, s
! Z" Q) s9 X0 a( r$ a
If ReportFolderStatus(FolderSpec) = 1 Then
, L/ k, L' p& t' V% q4 t( ]+ `
Set f = objFSO.GetFolder(FolderSpec)
) _8 ` {( `( n Z( C) E
Set fc = f.SubFolders
3 A5 N3 @7 x8 v, o8 E& K& L0 `
For Each f1 in fc
. N) ^; A$ ^ F( a; d* M
s = s & f1.name
# [9 t8 f4 O/ ~! F/ f3 _
s = s & "|"
: \1 e" j- j- p
Next
/ b0 J5 y* ]* v! E' p
ShowFolderList = s
; s- |! A) S1 G) d
Else
8 w/ B y: @8 k r3 Y: |
ShowFolderList = -1
/ r5 L3 K. i6 g; D9 b
End if
/ O3 `/ r' ?$ _' W s6 ]% B
End Function
! {$ j' ^ T) u2 x8 r3 H" M: ~
$ N5 _! R5 A. ]. E4 O' q
'目录复制
. h! `) E: n1 z. y( X2 B* P
Public Function CopyAFolder(SourceFolder,DestinationFolder)
* s- y7 y4 @/ s9 ?
objFSO.CopyFolder SourceFolder,DestinationFolder
1 h6 K& }) Q' g6 a, x
CopyAFolder = 1
7 |" u8 c6 X0 s/ v9 I E5 j
CopyAFolder = -1
9 C6 V( D' x- K( _
End Function
. E; A7 n: o8 n6 R* B
2 B% Z8 L6 W+ F( p' i, H2 j7 \
# ~' X7 ]' i4 F
'目录进行移动
+ r6 p8 E( T: P0 T [1 A
Public Function MoveAFolder(SourcePath,DestinationPath)
1 h- m: k# u+ f- A; h8 V
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
8 O8 N# g+ `% @' S. v" l$ b0 P
objFSO.MoveFolder SourcePath, DestinationPath
& X1 ` B6 f6 h: s/ [" }9 O% g
MoveAFolder = 1
/ Q, K2 Z0 q. {
Else
/ V7 @6 r# K5 B: O9 R
MoveAFolder = -1
1 {; r) p4 r- J# S
End if
, i$ _/ E2 D! F0 C2 V
End Function
8 t' l. i* K4 K7 r- ^2 S3 w
4 ?* G4 f. p# m |
'判断目录是否存在
+ @8 f: k3 f; b% Q1 |) f6 M! l
Public Function ReportFolderStatus(fldr)
% @7 ]9 [7 J) E* r
Dim msg
# h" z6 E2 R' Y2 Q
msg = -1
' `! B3 J5 K# S& K1 W- S4 S6 P$ @
If (objFSO.FolderExists(fldr)) Then
, S8 U* Z. z; Y e# \/ Q
msg = 1
5 A1 r8 b3 P8 C# J1 O
Else
# ?# c0 J- f4 I. o; p( e
msg = -1
* W1 I7 x/ c7 f6 q, A# F3 O5 |8 ?2 V
End If
/ w% d8 g$ f$ ~+ _% J
ReportFolderStatus = msg
+ b+ A+ \4 s3 B( x4 f( |3 a( i6 l
End Function
; @+ z, S9 [' w* Y
; Q* ^9 T9 A4 A& v6 A' f0 i: D
'目录创建时信息
: t. W/ |7 T- O- p
Public Function ShowFolderAccessInfo(FolderName,InfoType)
/ z* l1 I+ |& i) H5 O7 {# y
'//功能:显示目录创建时信息
( I! s7 {0 z- u" q, j
'//形参:目录名,信息类别
) k9 O" o) j, z" l
'// 1 -----创建时间
8 U4 Z" o0 @7 D: k7 E
'// 2 -----上次访问时间
7 B. S% ]) h& ?1 y9 v
'// 3 -----上次修改时间
8 O- H- L1 w3 s: w3 l' m0 r
'// 4 -----目录路径
( O- `% X7 d% M3 v7 O! {
'// 5 -----目录名称
3 ?3 R5 V! ]" B* B' F5 B. j+ r
'// 6 -----目录类型
: _2 A; d7 ?: z# A6 }* M
'// 7 -----目录大小
& C' V/ A# }) H# ~0 ~5 J$ V; g0 y
'// 8 -----父目录
% h* G: c1 ^3 V! V4 s# z8 u
'// 9 -----根目录
1 K9 ]# j% h2 C
Dim f, s
2 Y" N# O0 a7 @4 E2 P
If ReportFolderStatus(FolderName) = 1 then
. q- o' X) \* q- e$ r& ], _. N
Set f = objFSO.GetFolder(FolderName)
/ p6 n' E+ G; y) j
select Case InfoType
# R* A" V# N) ~' A4 w
Case 1 s = f.Datecreated
& U/ `0 H0 [4 N3 z W3 \2 y
Case 2 s = f.DateLastAccessed
3 Q- @. F( k+ Y" l( `+ ]
Case 3 s = f.DateLastModified
\4 }" j( ]. c& Q- r
Case 4 s = f.Path
. A' v! X7 J! o0 r
Case 5 s = f.Name
. G7 i' ^* v8 _ j% X
Case 6 s = f.Type
1 Z4 u% m0 v: c- a3 Y# N
Case 7 s = f.Size
' X4 P7 N. T0 b
Case 8 s = f.ParentFolder
* r4 T- q* f, G/ `
Case 9 s = f.RootFolder
r7 G, W: U( x: f" p
End select
1 c: z7 p5 h$ v5 z
ShowFolderAccessInfo = s
# K$ L2 d. q8 y3 M# @; j4 r n
ELse
3 c& Z1 J5 V+ m; g- n
ShowFolderAccessInfo = -1
2 z, v! b1 G; y
End if
2 ]$ N% m, J& F3 o- {& `
End Function
5 u' N7 n2 E5 [
) D/ F3 @0 e3 Z7 w
'遍历目录
& ?; O; l7 @ w. r" v( r0 u. Z
Public Function DisplayLevelDepth(pathspec)
5 {* b8 f+ z+ n6 X* \6 m) i; ?4 P
Dim f, n ,Path
: x$ f7 J5 S5 u, w7 x
Set f = objFSO.GetFolder(pathspec)
" `, d- H' \1 P' E7 _2 |" W0 a
If f.IsRootFolder Then
R6 C8 v0 w) q' ~
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
, ?% r- F3 d+ x0 o8 Z2 s
Else
5 C }; ~0 r& o* _9 X
Do Until f.IsRootFolder
. I, L% F" ^1 u* I. T& P& a c
Path = Path & f.Name &"<br>"
8 ~7 F, N+ o6 V; ^6 x( L
Set f = f.ParentFolder
$ o- [% |2 T0 [6 Y% g
n = n + 1
* n* Q' T- N4 D: x; _2 O$ F! K
Loop
6 A; Q0 O i& L( h7 `' A, t
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
! ~, h8 Q, n; N0 x, n c
End If
: b1 X! F2 E, h/ T8 g' c3 ?1 P
End Function
2 C% V7 \- @1 J! A) d" Y
6 W) v1 z6 g" k6 M
'========磁盘操作========
/ x8 j8 }* c4 v( L
'驱动器是否存在?
/ H% F: u Y& Z" O
Public Function ReportDriveStatus(drv)
3 E+ Z9 v8 |9 o
Dim msg
8 A7 \ a g& V; a6 _# f/ a
msg = -1
6 y K& U5 \/ y" N: `$ X9 { d) D
If objFSO.DriveExists(drv) Then
$ m& x; l! q2 O) ~
msg = 1
1 h! w0 {: b: k* T7 c6 ]
Else
. M; Q4 v- F. R" c5 {+ i( I
msg = -1
( T; J& o3 |2 F5 v
End If
v( V" Q' z* w" i% e+ Q
ReportDriveStatus = msg
& E" ?5 r- d) u. Q9 o) w1 |- b0 S
End Function
) U6 x' i/ b! O1 r8 Q% E7 J2 C9 V
* q! z0 ^9 y, M' P/ m" a- B
'可用的返回类型包括 FAT、NTFS 和 CDFS。
( \' T ~3 a. X
Public Function ShowFileSystemType(drvspec)
# \% |) F- u, N. S+ k+ E
Dim d
5 Z( ~4 W* Y. q4 B2 i+ H
If ReportDriveStatus(drvspec) = 1 Then
4 m8 c0 I4 D/ T% j' }. R5 P4 a
Set d = objFSO.GetDrive(drvspec)
4 v. c8 y+ y$ T# R# d
ShowFileSystemType = d.FileSystem
8 `; z8 G/ W/ m1 _* n
ELse
/ r( ?4 }6 I$ J! t
ShowFileSystemType = -1
3 Z2 R5 k! T9 `2 O4 h/ j& r
End if
. y# g' y0 U) y6 h* N. h9 x9 V
End Function
) K) i' }4 \' A' l( I4 S
End Class
' e: t7 f& C) O) `
%>
欢迎光临 【高州情】高州人深圳站 (https://0668qq.cn/)
Powered by Discuz! X2