- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6984
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1840
- 精华
- 6
- 积分
- 15415
- 阅读权限
- 200
- UID
- 10
   
- 威望
- 9084
- 在线时间
- 1242 小时
- 金币
- 6984
- 贡献
- 300
- 存款
- 1660001
- 最后登录
- 2026-5-10
- 注册时间
- 2006-5-10
- 帖子
- 1840
- 精华
- 6
- 积分
- 15415
- 阅读权限
- 200
- UID
- 10
|
ASP文件操作大全
9 w% P6 U; b3 i" U/ I<%
" I" Z- l0 i1 c3 r+ D9 aClass Cls_FSO # z/ x: N) M' `+ ]- _! _$ s H
Public objFSO * W- U9 U9 [& y7 V, A+ [' c$ S5 {* b
Private Sub Class_Initialize()
# a. E" X3 l7 b* vSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
0 ?3 O. b8 H+ F9 e4 YEnd Sub
1 E5 Z/ W4 h) m3 U( u# ?Private Sub class_terminate()
' t) E' F n, \; ^( X! SSet objFSO = Nothing 1 t6 l7 L3 s8 d4 Y( d/ E3 P: ]( J2 N9 A
End Sub " Z4 T8 z: a# q6 z: U5 W1 ~
7 g; V7 q; l& l! {, T'=======文件操作======== + s3 F2 E; u% A! [% S/ R G
'取文件大小 0 f. r/ R" T. e
Public Function GetFileSize(FileName) / l0 G9 N- i2 e
Dim f
- g. ?7 |! V3 sIf ReportFileStatus(FileName) = 1 Then
0 h/ l# A1 Y! @+ j/ l" qSet f = objFSO.Getfile(FileName)
: `! G1 E' y9 V, ~) ~GetFileSize = f.Size
, R# i# L ?% VElse
2 K( A3 u4 k9 f% g: IGetFileSize = -1 , D& x9 ^- h, | X7 f/ U$ \% n; N
End if ; F: C0 ]2 l, r6 @/ p7 S8 y; I. l P
End Function 0 k# r8 D' M9 N/ i+ r* F& ?
# w' W) h, A, j* b
'文件删除 ) d% N+ m. e9 ~
Public Function deleteAFile(FileSpec)
5 @' Z; I" O3 Z, y2 o. `- ?If ReportFileStatus(FileSpec) = 1 Then
x* z7 P& W0 n" O3 Z4 {. v7 mobjFSO.deleteFile(FileSpec)
' r0 b1 {% z* Q) y. mdeleteAFile = 1
5 f s0 G, Q6 D d& G* U; V# m* d, xElse + K/ _- J) B2 d
deleteAFile = -1
5 I1 z; k; ^* E5 O9 b. G0 BEnd if
9 c; M' J3 | ]# i4 V/ BEnd Function
: x) ^" W. t3 G; ~0 b' a2 P% z* g& v2 N5 I
'显示文件列表
2 p: U; o; c( Q+ W- OPublic Function ShowFileList(FolderSpec)
+ H! e8 k( V. n1 c% H" ^5 Q/ zDim f, f1, fc, s
7 R/ z5 {& |7 j9 wIf ReportFolderStatus(FolderSpec) = 1 Then
1 D1 R' p8 v: `3 @1 fSet f = objFSO.GetFolder(FolderSpec)
; P4 q% }% P7 ^8 a7 R# ^Set fc = f.Files
7 S' k: C6 G; f5 mFor Each f1 in fc 5 g% }7 P2 o/ t, e( R: g% V# O
s = s & f1.name
% }7 Y P8 [7 L/ w3 O Vs = s & "|" # C+ e ~6 n9 S. S. N
Next
. K1 E+ a8 K* MShowFileList = s 6 f% ?6 t( X- S+ V4 i4 \
Else ! j4 b6 _3 a9 k
ShowFileList = -1
2 C0 A6 X- |' F% V4 I' o& W9 a2 REnd if 1 M4 O1 U9 _1 F$ P! |2 U2 z! F2 Y% ?# s
End Function
7 @( o" v! Z ^" g# t5 J1 Y2 j0 @+ @8 |( p7 I7 Z0 y
'文件复制
. T: e4 I. g/ ]" VPublic Function CopyAFile(SourceFile, DestinationFile) ; g# Y( Y3 h; U* V
Dim MyFile
5 R k2 H1 l- ~If ReportFileStatus(SourceFile) = 1 Then # T* S& Q2 d/ y6 Q4 s$ w2 t
Set MyFile = objFSO.GetFile(SourceFile)
: g1 E Q! T+ y; ?& J& H6 kMyFile.Copy (DestinationFile)
_+ @% g1 y& x- w3 FCopyAFile = 1
6 y+ a! H8 C. l$ _; rElse + R- N. n5 x }% X( N i% p
CopyAFile = -1 - Y; l; [3 |& X" Q B* a. \
End if
# A. ]( K4 S- ~+ m( M7 T1 ^End Function
W; i) R& g! Y$ D2 G! L' D9 N# t5 \9 o& R
'文件移动 - p; K1 e$ J* s; K) d& O0 ]
Public Function MoveAFile(SourceFile,DestinationFile)
. u' @1 L/ L! l9 d0 L" T0 NIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then w- m, m: F( f: m
objFSO.MoveFile SourceFile,DestinationFileORPath
8 k% @$ z: v' {: wMoveAFile = 1
; F! @* W4 b/ J& [) ?( ~& nElse ! B' y$ D& v0 G i5 K5 K8 ~
MoveAFile = -1 / E; K5 i2 d9 E- ?8 d5 z
End if
x1 q6 ~) z5 M4 b0 {" n/ u8 {End Function
4 }4 X3 x; Z8 w7 g! w) A1 F% ~% F- g/ w# |) ~! `
'文件是否存在? : I/ p! H$ M* D% G' s
Public Function ReportFileStatus(FileName)
# ~, u" w4 B& h7 H. SDim msg $ f- w7 C4 q' n+ @
msg = -1
a; j" ]- G6 d( LIf (objFSO.FileExists(FileName)) Then
' s* T5 u4 w0 u" `3 \9 \msg = 1 0 k, ^3 e+ ~7 U
Else , F0 C9 G1 z. J, I1 K. H
msg = -1 6 R0 D) ?0 b( N9 }# j2 n% a
End If
) `$ @, C4 C# E! l/ a# G2 pReportFileStatus = msg $ ~/ S& v& {& I" `5 \
End Function " E# C _9 J& ~. S6 s" o
) P9 z/ t% l5 w/ [, a4 o
'文件创建日期 V k t2 X9 l ]# F; ~
Public Function ShowDatecreated(FileSpec) }, O9 e! R: b/ Y
Dim f 6 G# V' m0 i O9 _: H% D' _ W* `
If ReportFileStatus(FileSpec) = 1 Then $ N! R8 g; F# Z* q( v
Set f = objFSO.GetFile(FileSpec)
6 F* E- i$ I2 t* `1 VShowDatecreated = f.Datecreated
1 y, d m$ O; V- h7 }4 e9 m& MElse 4 a9 l2 A; r# ]" |! z$ m2 X
ShowDatecreated = -1
. O( a' ?3 \2 DEnd if
2 [5 M+ t/ z8 k* y2 V' KEnd Function
. q% M" a8 D2 K/ u+ D: C* P1 u2 h; j- n _- D$ D
'文件属性
/ W' @) x$ J. yPublic Function GetAttributes(FileName)
3 ~ ~, l4 Q3 A7 f0 J" |# lDim f
* X8 |# V8 _% E5 uDim strFileAttributes - W6 |- C* X+ r7 C+ O
If ReportFileStatus(FileName) = 1 Then
~$ w; U* C+ O. z/ KSet f = objFSO.GetFile(FileName) " W& N$ I4 w8 s4 @1 U
select Case f.attributes
" i1 F! m6 L# P" s% kCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " 1 V- {# w- c0 \
Case 1 strFileAttributes = "只读文件。可读写。 "
, b4 J+ {/ i- m" e0 `4 h4 |' uCase 2 strFileAttributes = "隐藏文件。可读写。 " * `$ `! A9 Y1 n5 |
Case 4 strFileAttributes = "系统文件。可读写。 "
) u6 ^% l0 i" e; oCase 16 strFileAttributes = "文件夹或目录。只读。 "
. s8 V" y; X5 V, b1 _9 b$ ], hCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " % q! l u& d7 U2 [0 S$ f7 N A
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " * k# n/ e8 M9 z% [ H' N# s
Case 2048 strFileAttributes = " 压缩文件。只读。" 9 r( i# W# m% r. o/ T$ M
End select
: e4 Y8 W4 A2 E4 a2 |* bGetAttributes = strFileAttributes
# w. h# P( o+ l8 ]" j4 |Else : l0 I* I. `, x3 N! N6 @
GetAttributes = -1 # g* U* R5 f; g" S; W+ Q
End if 4 R% V, N0 {( x1 G S7 j# _
End Function i9 N4 ?8 b0 K8 |. n
! w: b/ K% _% \2 R Y
'最后一次访问/最后一次修改时间
' g- A% X9 d$ f1 r; T: U2 VPublic Function ShowFileAccessInfo(FileName,InfoType)
F/ d8 Q( E9 t+ _ Z'//功能:显示文件创建时信息 ) V5 D+ J; q7 s
'//形参:文件名,信息类别
" G l3 _$ p. D9 @ A'// 1 -----创建时间 8 e5 q: a f9 A& e+ o! j1 E
'// 2 -----上次访问时间 3 {4 Q$ q3 a$ f3 \: n8 t
'// 3 -----上次修改时间
Z$ g" _+ g- c% \! Q'// 4 -----文件路径 0 h4 N+ A/ ^8 [( @0 Q7 |1 v" j
'// 5 -----文件名称
: }- m9 c3 h4 p9 k- T'// 6 -----文件类型 - R2 B' l8 A+ q* a
'// 7 -----文件大小
: |! _& w- i+ ^/ s% @- }1 o9 @'// 8 -----父目录 5 `) X7 h, W; i: I% n
'// 9 -----根目录 # E9 a. ?5 M' x( g! \1 O0 b# _- ~
Dim f, s
& z3 q' z5 F5 c; N$ IIf ReportFileStatus(FileName) = 1 then
R# }4 D+ K' b1 Z( P( {4 c8 cSet f = objFSO.GetFile(FileName)
# j% X# r4 s5 I4 D+ ~) o9 Cselect Case InfoType
' p: i: D; q& _* ^' i, E) bCase 1 s = f.Datecreated 4 e9 d, c- u7 l
Case 2 s = f.DateLastAccessed * q, L+ e& P, K: b
Case 3 s = f.DateLastModified 4 X7 v6 t8 M+ w
Case 4 s = f.Path
* f0 {4 t4 x3 ]' ZCase 5 s = f.Name # ^5 f* b# A; i8 W
Case 6 s = f.Type
) H' J8 v0 D# {. F$ _, \Case 7 s = f.Size
2 A9 C5 C0 s4 z3 `0 RCase 8 s = f.ParentFolder
. c( }; @+ T/ L; x& lCase 9 s = f.RootFolder 3 G! G1 P& y1 I# f7 A* {# o! A
End select 7 t+ ?. \$ P: C9 f
ShowFileAccessInfo = s
+ w& }; [5 P% V6 m3 t. ZELse
; L" L5 [+ ]) l, ]$ B, GShowFileAccessInfo = -1 1 @) Z8 G, F- ?3 n- Y
End if 8 ]# U2 p, B3 C
End Function 4 K, @+ o _1 j9 m
+ ^' Q& q5 v5 s- M! H5 `$ z* {$ ?'写文本文件
+ L8 y+ {" N) l# G3 ^% FPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
/ u- W( n# H ~) {Const ForReading = 1, ForWriting = 2 , ForAppending = 8 $ P. X3 {6 t2 h- B" p
Dim f, m ( c0 M. z; X) K m* s! v/ n6 e( g
select Case WriteORAppendType * ^6 X% `! i: ]' s3 O
Case 1: '文件进行写操作
: o/ x3 K0 c/ l1 r3 O! y, HSet f = objFSO.OpenTextFile(FileName, ForWriting, True) 5 J3 ]) M, A2 x& q- I6 ~3 G2 T
f.Write TextStr ' h% M v+ c. c2 Y, p/ S& c0 Y
f.Close 0 F( G4 K, W+ U
If ReportFileStatus(FileName) = 1 then
) J( S. I- k! s, g3 NWriteTxtFile = 1 3 f+ T' ~. W1 \
Else
. ]8 \5 k9 ?, X7 XWriteTxtFile = -1 6 x6 g& G) z$ A" B9 g# {5 [
End if
1 h" w! f( j' Y$ a5 ~Case 2: '文件末尾进行写操作
( P* U4 j; N4 F. d! _4 dIf ReportFileStatus(FileName) = 1 then
6 c- B1 T+ \/ m- l+ sSet f = objFSO.OpenTextFile(FileName, ForAppending)
9 s) t& ~& A0 Q% O6 Of.Write TextStr 5 d9 E" A5 K3 i6 `) N
f.Close # I) V. S* z* J$ r1 @
WriteTxtFile = 1
* A! K, {. k( o3 I' x- D' E7 {Else ' W6 \# |4 x+ |2 [1 o! _
WriteTxtFile = -1
9 T0 Q3 o. M. S2 d. S( QEnd if ! T* {( G" c% t/ C$ H& ^# N
End select 7 [7 {# b5 O& t0 k% I
End Function
- Q9 V# h& t1 Z! I1 m
- {0 ~6 d, G: g; E8 z$ H'读文本文件 ) ^6 _% L6 p% H3 G( [# z9 \
Public Function ReadTxtFile(FileName) , T3 G* M$ I% ~, n0 @7 _
Const ForReading = 1, ForWriting = 2 9 X9 ^* q8 S; N' M! t8 z8 ^8 u
Dim f, m
4 {4 k( x5 `' `$ O. hIf ReportFileStatus(FileName) = 1 then ( I0 z6 X4 D: C( H
Set f = objFSO.OpenTextFile(FileName, ForReading)
7 g- A% k0 [" tm = f.ReadLine ) u* {1 X8 [% U5 |& P, ~
ReadTxtFile = m
. n0 j: D- h/ z! E4 u% lf.Close + h s+ d5 s9 ]! v% @0 P2 |
Else 0 s. k) r1 }7 r2 r. f
ReadTxtFile = -1 ) h( h! j& @% H+ _
End if
' V+ H# B8 \, L% a" O" _7 CEnd Function & b2 `8 G8 G! |% n
; e( E+ d( t: @6 O: o. i'建立文本文件
5 U; I7 E. A9 X8 Q
% s" r5 Q& b0 @5 q7 X'=======目录操作========
, }; j/ A1 |5 v- {1 I( x( J# M1 ['取目录大小
4 T) ?7 u2 F) t5 F7 d! _Public Function GetFolderSize(FolderName)
T3 v7 ], x; I7 w2 `) c8 zDim f
1 d6 l4 {+ s0 C4 sIf ReportFolderStatus(FolderName) = 1 Then
$ v' B8 p2 ^0 N: v+ P. QSet f = objFSO.GetFolder(FolderName) 3 J* I |6 F$ w) g
GetFolderSize = f.Size
* Y8 v% J3 A2 OElse 9 G R. T8 U' h7 c8 F. [( E
GetFolderSize = -1
( V4 h- [* F* O# O% [/ ~End if 8 o9 X3 z7 j, [5 r$ W9 V4 {4 k
End Function
4 P% y! E: p8 V/ r4 |5 s& G# H7 A8 R2 e7 H
'创建的文件夹
7 B6 K/ Q6 g2 u9 RPublic Function createFolderDemo(FolderName) ' J$ x% a/ X2 j8 }4 {- }
Dim f
1 [, ]+ T/ T. GIf ReportFolderStatus(Folderspec) = 1 Then + ^/ t/ l5 ~1 C6 H% m& Q/ L1 b
createFolderDemo = -1
' H8 g2 W B! u7 Z6 g# m4 X! C3 \Else : ]9 a2 j9 F7 F* n: V; v
Set f = objFSO.createFolder(FolderName)
B) e: q* F4 R j/ \9 V7 EcreateFolderDemo = 1
/ e& J) T- ?( L* b: s" \$ s1 ?End if
; \4 |; T5 H. Q: m+ KEnd Function ( O0 T% h/ }: l5 n' z/ F
7 u" L( v3 ~6 V/ L- D
'目录删除 8 O% g% J9 b$ b
Public Function deleteAFolder(Folderspec) $ g) C* ~. l( _# G) \
Response.write Folderspec - W& r+ Y' p% X% Z
If ReportFolderStatus(Folderspec) = 1 Then 2 M4 S' q0 U8 j5 L* N* I6 i
objFSO.deleteFolder (Folderspec) # s) X, ]9 g$ S% O3 \
deleteAFolder = 1 # a" N$ |8 J! I- X2 L* o6 g7 f
Else # r- R( _1 k# k: d
deleteAFolder = -1
- x, i% y% c7 E T+ Z9 SEnd if a1 D: ]9 i0 b
End Function
7 R* u, y2 Q% L
* I' a- @. @* b# c5 p'显示目录列表
# p. J9 c' G1 x' C3 i' ]; o* KPublic Function ShowFolderList(FolderSpec)
* j8 L$ C J: W2 xDim f, f1, fc, s
( U0 }) h3 r. q4 D Y* yIf ReportFolderStatus(FolderSpec) = 1 Then # r% Y7 [7 `& M- d( l* U, {
Set f = objFSO.GetFolder(FolderSpec)
% M" Q( Y1 U" _, q& A+ SSet fc = f.SubFolders
/ E6 J, O" U; H. ^/ l+ z% U1 ]5 E: Y: cFor Each f1 in fc
9 T3 f! v/ ?+ J" _+ d; ls = s & f1.name
4 ?1 j* O4 j: n/ U! N% t- Ds = s & "|" ; C+ ]' c: Y& `) j
Next 6 z2 o4 {- e/ l' v* N I! l
ShowFolderList = s & c. D; p8 @; @* B4 s
Else . p* R4 U$ x% w. T4 J* f* C$ @
ShowFolderList = -1 1 Y! R! D7 s9 Z, o. O
End if # A1 L' V% K# p' s( k. h( P/ t
End Function ) V! n* C% `2 n( e4 D* C
+ a6 h$ e6 |- [5 V# m
'目录复制 " `0 i/ ^, W s9 U) a
Public Function CopyAFolder(SourceFolder,DestinationFolder)
, ^4 L }5 j. o; xobjFSO.CopyFolder SourceFolder,DestinationFolder
?( M! Y t: N: oCopyAFolder = 1
* @# h; @ M w5 I+ t6 ICopyAFolder = -1 8 X0 _2 H5 Z0 e5 W- @( ~
End Function ' S) X9 _, [6 y1 `4 l$ S" { M% O" I
# v- I& b6 f- C4 p9 c- h! x+ m+ g3 x, i r: S& o4 x4 ~
'目录进行移动 / S5 d5 U$ Z$ P8 _9 \/ q
Public Function MoveAFolder(SourcePath,DestinationPath)
5 W8 a4 e9 {9 T* U" N" r. QIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
' @+ z& V5 G9 W3 z2 G. y4 P* }objFSO.MoveFolder SourcePath, DestinationPath
2 x5 ~1 Q8 J% |# @MoveAFolder = 1
" j$ k& S" u! i" E2 E0 s2 CElse 0 G2 e4 ?5 [8 J+ ^! I. X! x, V
MoveAFolder = -1 ( J8 F1 k1 \$ B
End if ; T9 `8 v* L: X! a7 V
End Function - T. q; k1 Q8 X, r, {2 Q$ x- {
: o z9 P, \0 y. k$ }'判断目录是否存在
7 D7 F2 z2 s% O3 \" [6 @! KPublic Function ReportFolderStatus(fldr)
) g- S, R4 i% F4 U1 w& ^Dim msg . P9 p' q' W$ p& G( f' {! C7 G
msg = -1
9 G7 i2 d" p* E6 p4 Z$ SIf (objFSO.FolderExists(fldr)) Then
/ p# \2 ~+ D! e2 F7 S. |$ G& v3 w6 ^msg = 1
& u+ _7 z: O# @# \: JElse
! e# ]8 Z P, s9 Cmsg = -1 5 l4 s" ]) b, j; U
End If . u/ g: S5 k9 B2 s% E+ k
ReportFolderStatus = msg
+ |) v2 r: ~7 }3 MEnd Function - g6 i( b& ~% m; `( [8 P# n" J
- W: u( A6 H5 K' j7 ?/ {
'目录创建时信息 5 p+ l; l9 n5 ], W' J, c
Public Function ShowFolderAccessInfo(FolderName,InfoType)
3 O/ e/ H7 C( G9 x( @, B8 u, B, S'//功能:显示目录创建时信息
! d* S1 p) G6 Q4 i: K; m'//形参:目录名,信息类别 ; ^! v* C. q, W& ^/ V
'// 1 -----创建时间 5 Z5 ], u9 H# C" v
'// 2 -----上次访问时间 $ T# k' m# T, }' x
'// 3 -----上次修改时间 6 q Y" S5 U6 f# @! l
'// 4 -----目录路径
' J& k& D: c$ G, X; P: z'// 5 -----目录名称
5 p& e, b6 Q9 u7 D'// 6 -----目录类型
D% |: O+ I- d; U4 K4 N% o'// 7 -----目录大小 : e0 j' m' u/ {
'// 8 -----父目录 ) j, s2 J" } n5 ~! T
'// 9 -----根目录
9 [ S1 v7 K4 m- |& @8 m- R5 ]+ U1 zDim f, s 7 J) M" d9 F4 X& ]3 m; k K( b
If ReportFolderStatus(FolderName) = 1 then
; q$ @' L8 z: \9 USet f = objFSO.GetFolder(FolderName) 2 G6 J4 |7 }2 T' R
select Case InfoType h: ^; X/ z6 {% n$ A* {
Case 1 s = f.Datecreated 2 m8 w( j6 a" U+ w( @- `
Case 2 s = f.DateLastAccessed 8 `. B% Q3 P6 k; q4 N( p' J
Case 3 s = f.DateLastModified ( j l6 C7 e' L% z1 V# d: [
Case 4 s = f.Path
! a; r G8 a+ A" T) G! y& dCase 5 s = f.Name
% N5 {& g; ?; A* ^Case 6 s = f.Type
D4 x+ V: ?8 e5 p1 g1 c! T: ICase 7 s = f.Size : }! Q$ Q- A9 ]3 U8 d) l
Case 8 s = f.ParentFolder 7 V7 Q) F& c, W( h
Case 9 s = f.RootFolder
5 m0 j& E- o& k9 y U3 Z( gEnd select ( A+ {5 w& `5 o5 t
ShowFolderAccessInfo = s 7 B8 Z4 [' O& E- Z
ELse
" U k8 {, j# o" @ShowFolderAccessInfo = -1 5 G6 h" `; G$ D0 v8 Y
End if
- f" h8 H9 K" ]End Function
" B; d0 v r+ v+ b) Z8 V' F# v+ A) N
+ f4 |6 i8 n# X6 p4 G5 H'遍历目录
8 X+ Y* w1 c' ^Public Function DisplayLevelDepth(pathspec) 4 r; u$ s0 ?/ {* |7 l! L( x
Dim f, n ,Path / ^1 N. G% g* i* @$ S2 d; x- ]
Set f = objFSO.GetFolder(pathspec)
. W4 C) G% u* M, i; T3 k5 x2 bIf f.IsRootFolder Then
$ [% V+ N& _, vDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder : ^/ c) H4 a: @- a; z3 }
Else " o0 c& B# W0 S: E; q9 i
Do Until f.IsRootFolder
8 x1 ], k3 R3 q* f, tPath = Path & f.Name &"<br>"
: r& d$ \, i9 X, K+ I GSet f = f.ParentFolder
/ M9 L1 b5 n# [: |1 [$ Vn = n + 1 / T! s, b- A( u% g, @8 H7 O
Loop
) m! O0 r- F7 E! u/ MDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path I' ~' V+ L- w3 [
End If
) V. _+ P8 L4 FEnd Function
! C, k: H. Q" ]' p8 U0 K$ o; Q _2 w! L9 `+ V
'========磁盘操作========
5 w* `1 B7 a0 e# o. y/ C'驱动器是否存在?
2 ?* I: {" [( \- ]! r7 GPublic Function ReportDriveStatus(drv)
8 v9 O( O5 X& |% `8 C) G4 hDim msg
& E5 ~$ d2 ]8 D3 G: C: Q9 g7 Lmsg = -1 ' b$ `$ y7 c! m+ z3 z! P% }
If objFSO.DriveExists(drv) Then ; A9 ?5 f$ c2 F; G. v: Y: A
msg = 1
* J4 q! H U% R, K6 tElse + E5 B, h e5 s9 d; X3 c9 c: \. k
msg = -1
) ^* o1 e0 P. K" V9 @4 R5 {End If : R- a- B5 o4 U6 c( h( V- o
ReportDriveStatus = msg
$ k8 @9 ~5 h0 E3 x$ c6 a0 BEnd Function " w/ ^3 [! E* z4 J: a
6 |0 m) O" Z4 t6 e
'可用的返回类型包括 FAT、NTFS 和 CDFS。
' ]+ h( \- G" I0 \! VPublic Function ShowFileSystemType(drvspec) # `/ I5 X8 X i5 c0 h
Dim d
$ c" _0 o: z4 Z' WIf ReportDriveStatus(drvspec) = 1 Then
3 B! q7 y7 y l2 y MSet d = objFSO.GetDrive(drvspec) % z+ H O, X8 Y2 k" x1 p
ShowFileSystemType = d.FileSystem 3 q$ J: G" _7 r
ELse
1 D- Z# f* v$ Y9 qShowFileSystemType = -1
) f" C" N2 X9 N) ]3 f$ dEnd if / V$ K8 s$ r$ U5 W) h
End Function 4 t4 t; f) t: l9 j2 J; p
End Class
; H% B- @6 O. v' [' e0 ?* n+ R" ~) I%> |
|