- 威望
- 9151
- 在线时间
- 1302 小时
- 金币
- 7308
- 贡献
- 615
- 存款
- 660001
- 最后登录
- 2026-7-16
- 注册时间
- 2006-5-10
- 帖子
- 1875
- 精华
- 4
- 积分
- 25896
- 阅读权限
- 200
- UID
- 10
   
- 金币
- 7308
- 贡献
- 615
- 威望
- 9151
- 最后登录
- 2026-7-16
- 帖子
- 1875
- 积分
- 25896
- UID
- 10
|
ASP文件操作大全8 }, z, j9 L. S3 e
<% . X9 x2 j' G. F, M7 @6 f2 N
Class Cls_FSO 0 y( V0 k' T7 y# m: G$ a) {0 U
Public objFSO % z" R* j5 ]* F, Y, Z# X
Private Sub Class_Initialize()
" w! Z: a' I1 Y) u# c9 E! O% DSet objFSO = Server.CreateObject("Scripting.FileSystemObject") ! k) ]7 M5 ?. z8 f% a" B
End Sub
+ K v( J& g- v, }Private Sub class_terminate() 2 }+ P) k, k& t
Set objFSO = Nothing
, h$ @+ r+ r1 n% P- x) EEnd Sub ! S$ U h8 i0 Q/ x
! l3 @* W7 E* X, C8 h9 j'=======文件操作========
. G0 c+ M7 k7 H( ~: D' m'取文件大小
$ l$ J' _/ w( F4 K% y/ W4 pPublic Function GetFileSize(FileName) ; w; a2 }% `1 @! v5 M$ D
Dim f , G/ u" M- ` E* o# m9 Z
If ReportFileStatus(FileName) = 1 Then
6 t2 `9 p% C7 v' \& @Set f = objFSO.Getfile(FileName)
, N+ E0 J1 l) I5 xGetFileSize = f.Size
" V$ s' \6 M. pElse 3 Q0 n) U! f9 B8 r
GetFileSize = -1 5 Q7 l- P7 I Z& H1 a0 \, I- k
End if / J" p1 J' N! O& R4 I0 a
End Function
/ J: j. ~3 n# }( R3 H! I U# G3 k5 N5 |' _7 I P
'文件删除 6 g- G/ z z3 o6 Q
Public Function deleteAFile(FileSpec)
) L3 E+ j/ |3 G L: Q; p1 s) ?If ReportFileStatus(FileSpec) = 1 Then 4 K( F8 q" z4 [; S* d1 @7 T" [, O
objFSO.deleteFile(FileSpec) ' o6 q1 I. O6 @+ l
deleteAFile = 1 ( H8 M% V) a1 G& |" c% q
Else + G3 i r1 f) ^4 s. ^
deleteAFile = -1 / ^+ E% f7 I$ M5 F
End if
6 [% u) e0 y) D4 h3 m \( h% ^End Function 3 m( t$ D; _7 v3 N& d A& j& @" m
6 e+ [- Y/ `3 v, N, e& e* _% d* O'显示文件列表 Z& c; c! J$ m5 U* Q
Public Function ShowFileList(FolderSpec)
: d7 Y/ H2 K$ ^) M8 a, ODim f, f1, fc, s & p* W' `3 _+ N0 f
If ReportFolderStatus(FolderSpec) = 1 Then # Y! }+ N$ E2 h! @/ Q, k! i
Set f = objFSO.GetFolder(FolderSpec) ' h! F/ u, ?+ I- x [* k- e
Set fc = f.Files
' Z! k5 r9 i5 Q$ E& ^5 g; }For Each f1 in fc
+ K% m6 p' I% M7 ? A) ms = s & f1.name
3 e0 ?4 \' [ T/ Q! `3 Is = s & "|"
% O- X7 i c! A9 qNext 9 W! k1 b6 }( J
ShowFileList = s
+ E& c9 T: Z! J/ c3 v% ~) E; [Else 6 N) L1 M' @ l# W
ShowFileList = -1 ( G( n7 ?- D% J6 d: R
End if
" H2 Q- y$ o4 W9 {End Function
9 E% Q1 v" D$ [2 w5 F' ]* |
( |9 m4 V3 x+ `3 K& ^& X4 m'文件复制
* }$ n1 u2 c9 Z* X0 F6 o. jPublic Function CopyAFile(SourceFile, DestinationFile) + t1 U' C: ^2 M7 k1 F
Dim MyFile , ]7 K8 O7 L& f% p# T* H+ y* k
If ReportFileStatus(SourceFile) = 1 Then
A* h- ^3 K# n6 ^' e! TSet MyFile = objFSO.GetFile(SourceFile)
; Y/ x5 ]$ ` m9 E3 i+ k3 C# OMyFile.Copy (DestinationFile)
# p8 I' ]" Z! X1 f$ _ m2 \' O. R$ e: pCopyAFile = 1 % L1 `$ ?* ^- y, k$ |1 X: E A. _
Else ' L) u% r8 S7 A3 I" p- G
CopyAFile = -1 / r" u8 j/ T( q8 b* e
End if ! p1 A6 v2 N5 |" v% f5 M
End Function ; l, O z7 @' c+ Y3 H
; V3 m- c3 _* L
'文件移动
8 B8 U& r0 v3 L+ z) M' J$ g/ r& hPublic Function MoveAFile(SourceFile,DestinationFile)
2 v% e/ J* K, D. `If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then 5 p2 L/ Z* o. [. r" C1 \ Y
objFSO.MoveFile SourceFile,DestinationFileORPath # a" |/ U- H, @2 O e" P' Z
MoveAFile = 1 # z3 Q5 f, Z& I
Else - ^4 Q3 a* i; p
MoveAFile = -1
. V5 x' D$ ^: ^0 PEnd if ' {7 m) X- ~$ B0 S4 I
End Function 3 n/ D+ R# \' k) s) \! u
# q* l% L$ l# N' `5 D X'文件是否存在?
9 J% R1 ], d+ z: u9 M' D3 q MPublic Function ReportFileStatus(FileName) # T3 z# `. { D }
Dim msg 0 C) P' L* T( S. a1 i
msg = -1
& k( Q* d; K6 P4 KIf (objFSO.FileExists(FileName)) Then
& B7 I. h9 g2 t7 A2 k' E% D+ D/ gmsg = 1 8 l9 T+ f% a3 R- @5 P& p
Else
. H7 i* i) q) T7 _# [msg = -1
) p5 K( N3 f4 B. L) YEnd If 6 T& o& h; W4 ~- C7 c
ReportFileStatus = msg / B+ N1 X: q8 J+ P7 V
End Function : z |/ O$ q" j6 H3 f
" c. F: L* v; T" s6 j7 R ^'文件创建日期 3 B) R) s+ w& O7 ]
Public Function ShowDatecreated(FileSpec)
1 B0 d; u5 q! t( n& h2 a& ZDim f
; p6 V% o, ^& K: q$ Z/ AIf ReportFileStatus(FileSpec) = 1 Then
$ A. s0 R1 ~+ m2 y/ }Set f = objFSO.GetFile(FileSpec) + H0 s: Q* L4 ^3 s& K% C
ShowDatecreated = f.Datecreated
4 Y& F7 n0 B7 `9 S1 b/ KElse
( b$ i) E, g$ V4 [' Q5 eShowDatecreated = -1
3 A: E! \+ O: }End if * l, {3 b5 V+ l/ d2 b
End Function
3 B" c. W% ^5 o0 z% _2 z
* w! F+ z0 h1 }3 g4 g* A+ p) ['文件属性
{& ]7 s0 x' T$ FPublic Function GetAttributes(FileName) 6 u P9 T |$ D: S+ r5 l
Dim f
4 {" c2 w5 B' u* w' u3 w( MDim strFileAttributes * a* Q' d$ o7 s* F; n4 A, n) f
If ReportFileStatus(FileName) = 1 Then 3 X+ R; t4 g4 @$ E. _ z- d" N0 H! e
Set f = objFSO.GetFile(FileName)
- t& r4 G) Z& M2 B. E. ^select Case f.attributes 7 v6 a" d8 y' \8 Z1 }
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " + p+ z% h7 z" Q9 K( l" Y2 h) T
Case 1 strFileAttributes = "只读文件。可读写。 "
/ P+ A/ M( d& o! k; lCase 2 strFileAttributes = "隐藏文件。可读写。 "
" b) \4 I9 \5 n$ b& b+ E; aCase 4 strFileAttributes = "系统文件。可读写。 "
3 S! r' X: l3 iCase 16 strFileAttributes = "文件夹或目录。只读。 "
( O+ i" x6 M( |& u1 P3 pCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " ) B7 C }+ J& o+ l( [
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
8 l2 P9 W3 j3 w& F1 p, ~Case 2048 strFileAttributes = " 压缩文件。只读。"
! x" p' ^% c$ w( X1 s$ k( k, gEnd select
' ^3 v9 S: ^4 e q+ OGetAttributes = strFileAttributes $ y8 b- I- L, f7 C' V! d" \1 H7 P
Else ) R ?' z0 t) E" p
GetAttributes = -1 ; }7 B O& _, c M
End if ; M/ ~9 p# d6 g
End Function 3 C' F$ B! }1 ? S! f9 M- V) S
6 Y) h( S" a- A. y3 C' o'最后一次访问/最后一次修改时间 . w5 F( B) z* h. l
Public Function ShowFileAccessInfo(FileName,InfoType) 4 w) d3 M/ L9 e' O+ n! G
'//功能:显示文件创建时信息
9 r7 d4 c; p f) h2 G9 S3 M'//形参:文件名,信息类别 4 D& p+ e5 t, G* k" p
'// 1 -----创建时间 + K+ ~3 |7 \$ @" B# G7 H4 |
'// 2 -----上次访问时间
, F( K, [2 l+ c$ ?$ ^, ^* A'// 3 -----上次修改时间
% @7 \" v9 i, o'// 4 -----文件路径 + B8 L, J3 h* W; a. y+ S
'// 5 -----文件名称
- g5 |) d c: o+ Q2 h w6 ['// 6 -----文件类型
5 m* q% n4 H* `1 q8 z7 s4 M p6 V* f'// 7 -----文件大小 * ^6 c0 i& s# ?- }- k5 }
'// 8 -----父目录
: E7 E( ^! @0 t% Q'// 9 -----根目录 : u w' [3 f' Z r/ I# O
Dim f, s
# T2 a0 s2 B6 s6 Q' [" D% S* x0 C' m( C: fIf ReportFileStatus(FileName) = 1 then
) ~* C. U" s3 q4 lSet f = objFSO.GetFile(FileName)
/ \ d# e" a9 r0 h2 C* Hselect Case InfoType / Y' c1 J4 q: W. ?
Case 1 s = f.Datecreated & h: \& Q' A% A; L, P0 n- W
Case 2 s = f.DateLastAccessed . ?, X2 Y$ [" a g& L; [/ }
Case 3 s = f.DateLastModified ) H3 W/ V! o. C L) }4 [1 _
Case 4 s = f.Path " @+ W4 g9 [/ t% L6 ^6 V" y& F
Case 5 s = f.Name / @7 H0 h; c# ?5 v) b
Case 6 s = f.Type
7 ^) u2 j0 K0 P& `+ `" |. dCase 7 s = f.Size
- q- [9 k: e1 FCase 8 s = f.ParentFolder 5 Y- O# N' b: [
Case 9 s = f.RootFolder % b4 o# e9 d* U3 _/ R8 v5 H. B
End select
" j1 ?) |. n8 J& eShowFileAccessInfo = s ' u$ X0 r+ f$ r$ \ s9 { r
ELse
( k$ x( k R" O6 Z3 TShowFileAccessInfo = -1
" Q( S$ j7 T9 h9 o1 n# n! F# p1 [End if # X6 G9 Q* b& l
End Function * ]0 `7 t3 ]& E% S' ?5 ]
/ \0 d0 I7 t2 C( d/ D'写文本文件 . E/ l: x& t9 Y6 y( ?# S
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
) k, V. j0 q! v2 kConst ForReading = 1, ForWriting = 2 , ForAppending = 8
: v& v1 i% J0 _3 M- U/ f; FDim f, m $ K& b0 o& L5 z9 R- K8 c, O4 y' J
select Case WriteORAppendType
* H; Y+ r: b8 w/ o1 O' h* Q4 b3 J/ ?Case 1: '文件进行写操作
) N5 ~* X$ D$ M' F: ISet f = objFSO.OpenTextFile(FileName, ForWriting, True)
/ w4 t! P, M$ Nf.Write TextStr 8 |) \- D/ d3 c$ H9 H' ]! {+ L1 i
f.Close 6 a4 O1 q9 V9 s4 n b
If ReportFileStatus(FileName) = 1 then 5 S' J& E0 c- x
WriteTxtFile = 1 7 L7 E7 ?7 U2 M, j9 t3 Q" O! I3 ]
Else
; W) a7 V% Q2 K' |/ FWriteTxtFile = -1 : i- h- [/ i$ d+ q5 R
End if 0 i0 ^( U/ a! S/ M
Case 2: '文件末尾进行写操作 , `" q2 h0 L; p
If ReportFileStatus(FileName) = 1 then * S" M4 z& ?' v5 T1 A
Set f = objFSO.OpenTextFile(FileName, ForAppending)
; |1 Z M8 r: a0 L: Z. m' `f.Write TextStr 7 Q& a$ a% d, e, N3 w8 x
f.Close / Q$ t# J* Y1 V5 d+ y% z/ Q
WriteTxtFile = 1
5 z- O) w, |; o. h2 s7 D9 k( KElse
8 O1 c3 j( X, _WriteTxtFile = -1
# {% i. A, G& H0 A* R7 iEnd if
4 _: r( Z* {7 j6 [* F( J' b4 C- U( NEnd select
" k7 ~* Y" Y( O! }, LEnd Function / u& z; ~4 i0 x) j1 E, L
' B5 y- P/ H& m2 p4 B" |
'读文本文件 1 V0 X* E$ E U. Z
Public Function ReadTxtFile(FileName)
2 @( c0 V( A, E1 k1 {Const ForReading = 1, ForWriting = 2 ! W' x0 x! \- U8 n6 g& H( Z
Dim f, m % e7 p- l) h2 W Y
If ReportFileStatus(FileName) = 1 then ' a. v( n# K9 Q! i
Set f = objFSO.OpenTextFile(FileName, ForReading) ! {; r; p! e( P) \0 v
m = f.ReadLine 6 |) d3 ]4 ]$ n, k) M
ReadTxtFile = m
5 I. e v9 ]& O$ O9 c4 Gf.Close
9 v5 d5 w2 j) ^Else * [( m! Q: ^, c/ C- ^4 S. R0 M
ReadTxtFile = -1
7 X ^0 ^# m0 Q( r% J8 XEnd if 7 t& p7 U2 E( }! \5 h1 Z; h+ C
End Function 7 P# {, g2 O8 v
! c! C' |- S9 `# T; L+ s9 R
'建立文本文件 . ~: L% ~( `; j, i/ N
$ _; r% t! z/ x'=======目录操作========
0 d8 {5 b& r; |. }! F'取目录大小 # R9 f$ N" G/ I5 O
Public Function GetFolderSize(FolderName) 3 d2 p8 w, e1 r$ J6 q
Dim f 3 o. Q! A( P3 x' s. J0 ^ S6 h+ @
If ReportFolderStatus(FolderName) = 1 Then : Y0 o- F: B& u- Q
Set f = objFSO.GetFolder(FolderName)
2 j' t) D! R+ Q7 n8 ?. J6 L- a, zGetFolderSize = f.Size - U) z4 Z7 `# T0 S/ I$ n |6 b
Else $ i3 k y5 O4 G+ y+ x* _1 O W
GetFolderSize = -1
8 A( p" _6 _; |End if
% v5 [) l+ d# GEnd Function 0 ^) {7 s- C" H& [0 `" Q
, n# t: C0 Q! F'创建的文件夹
- T$ n1 u- V' n5 O+ g PPublic Function createFolderDemo(FolderName)
A; d2 ?5 y$ H% `Dim f
' w: ^+ v, H5 dIf ReportFolderStatus(Folderspec) = 1 Then , N# I' U5 _& R/ j
createFolderDemo = -1 / U+ f2 @5 R. X8 n$ M* E
Else " E" b3 s+ T! P" N2 G
Set f = objFSO.createFolder(FolderName) 1 K6 X# i/ K, p* s) t' P' G' t9 F
createFolderDemo = 1
. O/ h+ S+ C% Y8 |End if . U# |6 g9 \4 H. n% F
End Function
' | X: O8 D2 b9 p( u4 J$ m2 s4 ^* l! C( M0 T [
'目录删除
6 W* i. M6 e0 }. \/ {: ` F; DPublic Function deleteAFolder(Folderspec) / p3 P- z8 D& b' k2 M$ Y% ~8 K
Response.write Folderspec
; W4 l+ A: @; F; Z1 i. I, rIf ReportFolderStatus(Folderspec) = 1 Then ) d; |* b' {1 x6 ?7 r2 k1 |
objFSO.deleteFolder (Folderspec) ( p: y! B2 J$ D* R$ @: w: O
deleteAFolder = 1
; u& ]) P0 _1 |5 {- RElse
! H/ g. Y! q7 W+ `% MdeleteAFolder = -1 8 _3 S& C. `( a- h
End if
8 {5 m" C; W( D7 M4 tEnd Function 1 c' N7 r- `: D$ Z
3 i% F1 ~8 r$ ~8 h3 \
'显示目录列表 % W0 @+ u) t) @, E
Public Function ShowFolderList(FolderSpec) 5 E8 b3 M: ]" S0 I/ C
Dim f, f1, fc, s 6 {, J# M% C& u9 s% g
If ReportFolderStatus(FolderSpec) = 1 Then * b6 S# z3 t/ l! M/ s
Set f = objFSO.GetFolder(FolderSpec)
/ M# o V0 T! \Set fc = f.SubFolders
# E4 V$ L1 o% [" S# B* E8 kFor Each f1 in fc ( A1 V6 w. Z- k7 v( J5 w
s = s & f1.name . e# G9 x0 N. D. |4 k- E2 O3 z' e
s = s & "|" 3 X, [' s+ X8 {3 H. E0 }6 @
Next 6 m" A3 ~6 s3 q2 r2 n) C
ShowFolderList = s
3 w- K, d4 W ~' _Else ; z D/ q' F' M7 o' p. ~( d
ShowFolderList = -1
- I9 {. I5 b9 i6 WEnd if 3 r3 B0 t4 k4 f
End Function x1 w8 n; ]8 L4 N( r2 d
0 }2 z% |* t5 ]* T, z'目录复制 0 }( m4 L% [, X7 T/ U+ K
Public Function CopyAFolder(SourceFolder,DestinationFolder) ) k+ v4 E [% g3 i' _
objFSO.CopyFolder SourceFolder,DestinationFolder ( G& G* I7 F* N- f% i# w6 l2 i
CopyAFolder = 1 + ?4 G+ _$ [7 u# J" c1 l
CopyAFolder = -1 - \) V% s6 B5 b8 ~3 X- d2 P1 ]/ M& [
End Function
5 a _8 x9 x, c. A$ ?& j8 n& D$ y& ?6 |( N6 G+ `. _
1 L: I6 d# [. H'目录进行移动
& `$ o$ s! T: _: W8 O" xPublic Function MoveAFolder(SourcePath,DestinationPath) " m8 _. v* @4 I) `3 X; J5 q
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
: w" A1 v& Z) G2 MobjFSO.MoveFolder SourcePath, DestinationPath 4 V+ k: `0 r' v0 M6 v& @9 E
MoveAFolder = 1 ! l) t$ C9 o4 R: w. q8 D4 t" D5 }! [
Else % f8 x; q- d2 j7 i& R z+ d) M
MoveAFolder = -1 5 ~4 V) x- n/ s' E- h; S% J1 Z
End if % O5 ]. [* ?" H O5 U) K1 ?% C. E% I# P
End Function : i, C5 m6 r4 N; R/ y; S" w6 P
, |8 b% n+ M/ A1 g8 W1 a5 \, L
'判断目录是否存在
J# l5 h n' vPublic Function ReportFolderStatus(fldr)
6 {: [# D$ g* o6 Y: U6 T4 v9 PDim msg ; J; [5 l9 W1 T3 b
msg = -1 9 [# R E" J! c; }" }# E" K* m% j
If (objFSO.FolderExists(fldr)) Then ~; u, Y7 _7 E$ \/ m
msg = 1
6 _; t( \2 y' A' y/ _Else ; ^0 t8 {& O- y5 V
msg = -1
2 {2 M/ \$ H) eEnd If 9 x6 k4 o4 J' N2 J, A2 S- M
ReportFolderStatus = msg
0 u" F/ t1 T" N9 L( P: r& vEnd Function
& V, v1 e6 Q. e; ?; w* h; x
: T3 L+ G6 E, q'目录创建时信息 & d8 d" N% `+ R+ ?( w' v( u
Public Function ShowFolderAccessInfo(FolderName,InfoType) 3 z0 H9 I7 R7 R& e3 o4 g" j
'//功能:显示目录创建时信息 " b! P/ w4 U7 S7 w& m6 n
'//形参:目录名,信息类别
, V/ |4 N" f6 n) A0 u' m! u'// 1 -----创建时间 " ^6 c% [4 p: @
'// 2 -----上次访问时间 ) B/ @: X. _& g* M
'// 3 -----上次修改时间
; @0 d; K( L0 }) t. H'// 4 -----目录路径 0 b& y U$ C* W0 q6 A5 r2 p
'// 5 -----目录名称 2 \# O) b% }' T5 a, ]+ v
'// 6 -----目录类型 9 _( n, W0 h! f5 z3 J" T$ s
'// 7 -----目录大小 3 p" }5 b" I `% g
'// 8 -----父目录 9 L/ D; C2 v0 W! u( r
'// 9 -----根目录 , X4 a/ x2 `' q4 R8 w# Y8 R/ p
Dim f, s . e+ y, R V. f: h( H
If ReportFolderStatus(FolderName) = 1 then
1 _* e( E2 f( m, |" m0 E. p% t: wSet f = objFSO.GetFolder(FolderName)
& g& y- Z1 p* l0 [- g1 qselect Case InfoType
0 i, J! R, y$ t* l% f4 ICase 1 s = f.Datecreated
1 [8 `0 o6 E- a1 h5 D) hCase 2 s = f.DateLastAccessed
/ \& |) q2 L3 L: a2 \Case 3 s = f.DateLastModified . t* h/ H' J4 V5 I
Case 4 s = f.Path ' F. l8 Y* e& q
Case 5 s = f.Name
' x5 [. c4 d7 {0 W4 @Case 6 s = f.Type : s9 o1 [3 R5 T% L! W5 U0 E# K: E' z
Case 7 s = f.Size 4 w" A. N# ~+ h6 M" k/ G
Case 8 s = f.ParentFolder 8 f" V6 p' n" Y! ?& v2 {
Case 9 s = f.RootFolder
! f$ s5 S: R( u7 E" g xEnd select
, R% g; h' W$ J& h- hShowFolderAccessInfo = s
. M( o2 p$ [0 O& x# pELse
1 k1 Y% g9 v, o4 ^, qShowFolderAccessInfo = -1 ! w! i7 {6 ~4 _7 {- \6 s
End if
7 g9 M+ J" y# YEnd Function . J' X' N; t2 X4 D6 x
5 `! a6 r. {7 h" e9 |- A4 c'遍历目录
' F* N# x$ |8 H+ ?/ Z6 B6 ]9 WPublic Function DisplayLevelDepth(pathspec)
) a5 a5 m) u; kDim f, n ,Path
" k. z2 p |2 a8 y7 N# L' {, V( `Set f = objFSO.GetFolder(pathspec) # Q" i- D: U% t1 Z/ `1 U' q
If f.IsRootFolder Then
2 |0 L. K& h- w7 WDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
7 a& d: v q; X8 o4 _8 Y! Q( wElse
/ n7 O3 J$ R m( HDo Until f.IsRootFolder
+ i# I2 o* |( D8 m8 mPath = Path & f.Name &"<br>" . H; t) q4 @7 |( J2 j/ s+ T8 S3 ^
Set f = f.ParentFolder 0 h4 q6 {4 ^/ C' A9 g
n = n + 1 8 N0 b# p* r" P& A( M
Loop
. L& N0 P' ~# s& LDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
+ e6 r7 ^1 L! J9 S1 f/ v; BEnd If
- i) H" ~: [. z( HEnd Function
8 O) Q, h" A8 \! k- R+ {
+ G! K4 P4 m- w7 T/ D: m'========磁盘操作======== / y6 i# L3 a, U' ^. j$ D
'驱动器是否存在?
; ]& r6 q# q6 i7 FPublic Function ReportDriveStatus(drv)
5 a5 ^/ ^1 Q3 F) S0 vDim msg
' J8 M) ?0 u( Q3 mmsg = -1
. t: X8 ]3 h7 t. ]3 o; `If objFSO.DriveExists(drv) Then
7 U- G- i/ m& L. C+ D5 kmsg = 1
# G1 H2 o) ~* a* N8 aElse 7 n( S' J- B8 ^$ |# C
msg = -1
0 W& I" Z7 w* z. rEnd If
9 j. ^: O- z5 J1 sReportDriveStatus = msg 7 x5 Q' a. c& C# t3 j
End Function
1 z2 J y8 `5 S, q; v7 q1 v, Y% j6 p5 }# W7 L: R$ L/ y: |) X
'可用的返回类型包括 FAT、NTFS 和 CDFS。
, n! i: j$ V3 r3 UPublic Function ShowFileSystemType(drvspec) / O4 |3 t. ]. u {+ K9 h1 E
Dim d
- t# E' ^" f/ \: IIf ReportDriveStatus(drvspec) = 1 Then
2 Y5 U: v# c7 bSet d = objFSO.GetDrive(drvspec) , @2 I" w0 J3 x! @' l4 [
ShowFileSystemType = d.FileSystem : E* @; f# T( Z; a
ELse k5 k: V% A! G/ |
ShowFileSystemType = -1
( v2 ?! `2 I; X) b. P7 W' n: VEnd if
" h- y6 ~. R5 p7 Q QEnd Function
( c. U- Z! ], I2 `; }End Class
" i! }+ i: Z. s$ ?%> |
|