- 威望
- 9151
- 在线时间
- 1303 小时
- 金币
- 7319
- 贡献
- 615
- 存款
- 660001
- 最后登录
- 2026-10-4
- 注册时间
- 2006-5-10
- 帖子
- 1876
- 精华
- 4
- 积分
- 25897
- 阅读权限
- 200
- UID
- 10
   
- 金币
- 7319
- 贡献
- 615
- 威望
- 9151
- 最后登录
- 2026-10-4
- 帖子
- 1876
- 积分
- 25897
- UID
- 10
|
ASP文件操作大全
/ l* a8 D( {7 d; O S0 T2 v" r7 I<% 2 N! B$ X$ a% J) E! R
Class Cls_FSO - H" |4 g( K& y& t
Public objFSO $ A) U2 L8 N3 [, V( L) W
Private Sub Class_Initialize() . R# R& P( u6 x5 S" N' {2 e- a$ B
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
3 ]% K$ i- D& A$ w4 y0 ^End Sub - Z0 Q, K. ?9 V+ p! C- K
Private Sub class_terminate() ) G/ w& v( M b) M: s2 G
Set objFSO = Nothing 7 }3 g4 s, c3 x6 c3 f
End Sub - M5 X" h6 d3 ^; j- K" u: w( x
) X8 T' _ f: g; n8 N' W' S
'=======文件操作======== + R6 |% E* M, A# l6 v7 q
'取文件大小
3 g5 d) C* N2 H4 x5 L; T, |Public Function GetFileSize(FileName) 1 A& C; d q" V3 @
Dim f - D0 Q. m9 ^2 e7 P' `. S
If ReportFileStatus(FileName) = 1 Then
, m) E3 o0 f8 [7 S3 B; @. |& f, oSet f = objFSO.Getfile(FileName) ; n0 B- r4 W8 p N( R |
GetFileSize = f.Size
$ t# U$ Q; R( o, _0 RElse 1 @" I4 j5 \. i1 B* k b
GetFileSize = -1
6 i Q8 {& O+ S/ t# v+ aEnd if
* b$ M Y0 Y3 lEnd Function & @- ^7 i! v2 d. d7 i" p
$ u; d1 }5 V3 _2 o; y, a'文件删除 , D" s3 ?( X+ ~3 e/ p! c
Public Function deleteAFile(FileSpec) - e4 l L1 p4 M# [- s1 Q# S' ]" O: B
If ReportFileStatus(FileSpec) = 1 Then
9 k# V5 M+ B+ N( ZobjFSO.deleteFile(FileSpec) 9 _' ]. g! v7 A* W. r; s! Y
deleteAFile = 1 4 k! k% o7 Z [
Else
8 Q+ }/ z2 h1 j$ P) ^1 L4 RdeleteAFile = -1 + B5 h. S! W V7 K
End if . Q" r3 @% { X/ [' f# D0 I
End Function 3 p/ y8 S0 x g/ w# r
3 ^' O0 e6 |9 m. D; y) ~. D'显示文件列表 ! g2 ~' U. T! |( f3 q' |- _+ i4 f
Public Function ShowFileList(FolderSpec)
% l3 Y! E5 E4 u# b! h0 a, u# n0 fDim f, f1, fc, s % [1 [) x/ v) p
If ReportFolderStatus(FolderSpec) = 1 Then 9 l/ `7 \$ c1 W8 |0 ^% O
Set f = objFSO.GetFolder(FolderSpec)
) _& ^: ^+ ^) m: T8 j0 U kSet fc = f.Files
+ P4 H7 p4 a7 x. A: R5 e- y! x6 S0 \For Each f1 in fc 0 g( E" x8 D% s& I, |1 D7 w, I @; s
s = s & f1.name ) F4 e) @! b: ?1 ?
s = s & "|"
( E6 {5 I$ W% C! g# C- l% HNext S& R$ l; G8 R. |3 Y( F
ShowFileList = s
+ t* j: ?( r$ s7 ~" P$ }7 IElse $ g. f( Y! ]* {3 r6 k) H5 B- L
ShowFileList = -1 4 O& S" B1 h/ ?2 C4 V9 X
End if % L( l j" @+ K& w% i4 h) R
End Function ! H5 w8 Z: o+ o: ]5 y) X% U1 z
1 ? S, ?2 y# V7 M$ k'文件复制 9 K# m. v% |- v
Public Function CopyAFile(SourceFile, DestinationFile) / f- Y+ o" F$ E ~
Dim MyFile
Q9 @9 G" D5 b& @# r R+ P6 \If ReportFileStatus(SourceFile) = 1 Then
9 K. N$ g1 k% ^$ X' ESet MyFile = objFSO.GetFile(SourceFile)
2 P9 _+ \) s7 N, J5 h& [: _9 OMyFile.Copy (DestinationFile) ' V! a- W3 J: ]6 |7 J1 U+ f1 z
CopyAFile = 1 ( ^5 c6 ~9 O, @& V6 P3 S
Else
8 s X' x" [3 Q9 _9 _$ J( TCopyAFile = -1
- X; \1 S7 N+ {+ X( \End if
( W( D2 l( a. \8 |# o, c3 ~2 A* BEnd Function ; E; `1 {) U9 j! K/ C3 A
& N/ F1 F8 o( {8 M
'文件移动 ! @1 Q8 ?% @* [5 y- U
Public Function MoveAFile(SourceFile,DestinationFile) + J+ O7 `2 u7 g o. _! _9 F( |
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then ; g5 v: o: j) I! G& h
objFSO.MoveFile SourceFile,DestinationFileORPath * \1 I3 N, _* a9 J; E6 |0 ^: E6 u" {
MoveAFile = 1
; _6 S, F5 R$ o# fElse
+ g! h( `0 T# o5 g0 w" W- G1 sMoveAFile = -1 7 v- H, s3 f* t9 D* ~, U
End if 4 n; {2 A& p4 ?" x7 L
End Function
" V" [6 k" C9 S; D0 t8 [( T5 q5 M7 ~% f' C
'文件是否存在? $ q: l/ D3 x& j3 f% @3 ~! ]
Public Function ReportFileStatus(FileName)
' ~3 G) Y5 a! ODim msg
7 B# o) a' p3 G" N9 P6 \msg = -1
# }4 ~) i) e# \ P. ?6 xIf (objFSO.FileExists(FileName)) Then
3 [( D8 h% o. F: C0 [. Umsg = 1
- D$ v2 m) x2 N3 N$ O+ [0 K6 ~Else ( C5 ?/ T& ~; F2 Z/ t# J3 X, q
msg = -1 " i$ i. b0 ?8 _% W
End If
' R' ?0 ]5 {: C* V/ P* v- M2 y1 [2 tReportFileStatus = msg 1 v, b9 `* }: z1 |* J- Z
End Function
" Y0 }; _; g& J9 p
& @' [: R8 Y+ z/ B, j$ Z3 [# G'文件创建日期 X; K& v& G, I ?5 A
Public Function ShowDatecreated(FileSpec)
6 t: H$ V& }) B" S/ V: Y$ V/ MDim f . e( G1 |9 p) @( {% H
If ReportFileStatus(FileSpec) = 1 Then 6 R5 v6 p9 _$ a+ ~! } V
Set f = objFSO.GetFile(FileSpec)
( c+ b/ ^$ Z' l" P8 n6 A5 c- t5 \ShowDatecreated = f.Datecreated
$ `2 D" b' S v7 u# Y( rElse
9 F4 V6 e- S' e8 `ShowDatecreated = -1
9 w9 `5 B6 h8 lEnd if
; E/ {/ M- F* a8 ^End Function
4 x! m$ N/ o b+ @. O1 a2 u( \1 b8 {7 v2 s. F- F3 a- h7 R: R9 `0 k
'文件属性 6 T9 j* j8 p) |& k$ z) X0 |
Public Function GetAttributes(FileName) % N' y4 o: ]8 U7 z: ~5 y( p3 K: x
Dim f
4 K) B' b! b. Z8 kDim strFileAttributes
0 T: L' A* w8 D/ S+ K% [If ReportFileStatus(FileName) = 1 Then
, \8 n5 a; e0 [Set f = objFSO.GetFile(FileName) 6 L, e9 G4 d) ` K* P
select Case f.attributes
4 F/ C) g( P3 L; B$ tCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " " _. d* M3 p5 t( j+ E' D+ S0 a
Case 1 strFileAttributes = "只读文件。可读写。 " & h. x- a7 ~. a6 J
Case 2 strFileAttributes = "隐藏文件。可读写。 "
6 k2 F' g7 E1 C/ c/ XCase 4 strFileAttributes = "系统文件。可读写。 " ; J) u+ E( T5 q5 P8 g
Case 16 strFileAttributes = "文件夹或目录。只读。 " & Q( ]3 n9 v/ w
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
3 F8 h% V+ @4 E1 m* T; aCase 1024 strFileAttributes = "链接或快捷方式。只读。 " 0 p1 t/ m. }* m& ]7 g- n
Case 2048 strFileAttributes = " 压缩文件。只读。"
. F# \1 R3 L* `! n/ kEnd select
( K5 D9 m/ X# E" z& I" k/ h4 ~GetAttributes = strFileAttributes ' t- w9 M" [8 f4 ], r, N$ e' T+ F2 t
Else
4 Y" k) s1 m6 b. j( m* @ r! |GetAttributes = -1 - g/ ]3 G9 o; p) h
End if
1 @6 {2 I& J+ H( }End Function
& @2 ~7 a: `4 v' E7 p, u; i Q! Y
- d1 q' M1 r- B5 I+ G2 Q'最后一次访问/最后一次修改时间
. W2 r1 k, Y# n9 w! b* D, OPublic Function ShowFileAccessInfo(FileName,InfoType)
% h# ?0 R/ r9 i; _'//功能:显示文件创建时信息
+ U2 J- F& ]' D, B' _3 Y'//形参:文件名,信息类别 ( C" t) I+ s {/ r& s
'// 1 -----创建时间 . G1 i' N6 b1 l) j, K3 q% J1 A
'// 2 -----上次访问时间
5 j/ ]5 r' M6 m* S0 n) C'// 3 -----上次修改时间
! `& T2 Q6 l5 @4 Q# @'// 4 -----文件路径
* `, p; c. x0 K- X1 n7 m'// 5 -----文件名称 & l& `. ?: Q' |
'// 6 -----文件类型
/ n9 Z3 E2 N/ R* h0 @'// 7 -----文件大小
9 `. I4 ?9 J8 G- N'// 8 -----父目录 - w8 b4 W/ G6 Q+ u
'// 9 -----根目录 ' T; Q8 c3 W& Q0 _& t
Dim f, s 7 A1 P0 ~1 W6 r: _
If ReportFileStatus(FileName) = 1 then
: A U- Z* @- v. x, x7 h5 }Set f = objFSO.GetFile(FileName)
6 y/ e0 ]( e5 V0 I) wselect Case InfoType
# ~: x! K7 P' _7 V zCase 1 s = f.Datecreated
1 V J- g* d; j4 }' @5 x& B4 m) lCase 2 s = f.DateLastAccessed
2 j* B( _8 P+ y2 w& P0 ]Case 3 s = f.DateLastModified
$ f. I# W2 ^9 V4 ^/ m* {/ ^2 E5 j0 uCase 4 s = f.Path 4 b7 i! z+ E& @0 R: k8 j" G; H
Case 5 s = f.Name + F3 Y% c. A! f3 h+ @
Case 6 s = f.Type |! T! U5 y0 }( f3 s" i! F' O
Case 7 s = f.Size
, e% N+ i0 G! ^# g+ c! \0 BCase 8 s = f.ParentFolder : }# N* t8 t! `' B$ ~+ O
Case 9 s = f.RootFolder + ~6 _7 E1 `0 {9 d! c( B$ v- _
End select
! [. h. k5 d+ m, U# w, UShowFileAccessInfo = s ( o/ Y/ v4 R, ~, r n+ o
ELse : ]4 t5 F# v9 ?
ShowFileAccessInfo = -1 Q0 a+ J* t% Q4 X
End if " H" {: W# S+ C3 m7 h9 R
End Function
4 Y6 U3 b I+ v N7 u5 V! J
; P4 T! x3 A9 h5 W* l'写文本文件
- o% D0 @% Q0 [Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
- p. v- ~; U- h9 q8 IConst ForReading = 1, ForWriting = 2 , ForAppending = 8 : \& x- g- @' r
Dim f, m
7 ?3 u# L* q. Y9 Z% G$ @1 Y- v- Uselect Case WriteORAppendType 0 ~+ A& _& z9 u% V. A$ I8 _4 P
Case 1: '文件进行写操作
! y5 t: R, @& s8 {Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
) V: v5 G% y* D- Y/ z0 c0 uf.Write TextStr
) A8 m4 V# f* N1 v5 F7 J0 Sf.Close 8 o0 i% x2 {9 h4 v. t" @/ [$ y- j
If ReportFileStatus(FileName) = 1 then / I, y9 P8 b* d# j- m$ m5 i4 I6 {
WriteTxtFile = 1 ( B B3 M3 d3 j$ Z' p
Else
& \% h5 H+ y: f9 B- w7 DWriteTxtFile = -1 ) x3 j) ~6 o& K' ]
End if " u4 x3 U* |% j- Y* Z
Case 2: '文件末尾进行写操作
3 T' M) _8 C' m G5 eIf ReportFileStatus(FileName) = 1 then 8 M* J6 Z, _( R# M
Set f = objFSO.OpenTextFile(FileName, ForAppending)
9 l2 U& a/ s7 h, h% Uf.Write TextStr ! C- Q' x5 Q9 `
f.Close & X' M. K8 P8 g' f. G: K: Y
WriteTxtFile = 1 * W8 J8 S# _# v5 U
Else - x- ]1 t0 ^9 y* A( W0 I. W$ e
WriteTxtFile = -1
/ U( a' g. s; w! o- }End if
0 M, O1 `3 g8 oEnd select
& o f: Z# A: U: K" ~( FEnd Function $ I) p( V1 p# C7 O+ f
! C5 _8 j# G2 o( R) u# n D1 ]2 i'读文本文件 ) x1 Y9 H7 f) b) o3 o" v( l
Public Function ReadTxtFile(FileName)
$ _) T( q2 X) E5 E3 l; mConst ForReading = 1, ForWriting = 2 . `: K( `: s. e
Dim f, m ' m- m' h8 G" K) j2 M
If ReportFileStatus(FileName) = 1 then 1 W% ^* f; f" @0 t3 Y5 t0 f
Set f = objFSO.OpenTextFile(FileName, ForReading) 1 w [( ?8 a# x# u/ }. u
m = f.ReadLine
4 i) X+ B" n+ ]& @3 v9 x- O0 IReadTxtFile = m
. C, A8 I- ?& @5 `" ~" `+ k4 {+ |) jf.Close
8 I$ _7 d' l- W' z2 H6 SElse 4 D) D! P& C1 f2 d
ReadTxtFile = -1
4 t' s0 a# a& y, f8 L6 U4 ZEnd if 0 ?2 ?5 ~/ J6 b5 ?
End Function
* T- L! ^* x5 G* E+ z. n
8 E* L6 r* c8 }! [2 w+ p'建立文本文件
: x# w$ r! n* Z8 `2 \2 [; J" n$ S% ^- y' ~5 Z
'=======目录操作======== 6 `8 S0 A, P# Z. H3 G' M2 c6 e
'取目录大小
9 m& N$ s b: W* \2 Y% G) d* z6 S9 iPublic Function GetFolderSize(FolderName) ( s# B4 M' ^5 S ~- V# o
Dim f
, b% o) t9 S. N0 o; U- KIf ReportFolderStatus(FolderName) = 1 Then " \) z: Z2 c# }4 c W* a
Set f = objFSO.GetFolder(FolderName) ; E6 J+ K) Y+ g% W* Z
GetFolderSize = f.Size
. m9 W, | `- GElse
* `3 L2 f8 h' C4 N8 {) TGetFolderSize = -1 . Z) @7 x( r" w, @8 K- y2 ?
End if " Y( H; K% ]- E2 ]
End Function
$ H1 X& y4 J8 \5 v: q4 }' w0 X* F! d: [, a
'创建的文件夹 - F) H8 @7 z8 i2 w# q0 Y
Public Function createFolderDemo(FolderName) ! C) X% j6 o) [4 D6 G* r4 h
Dim f - d$ L: ?, `1 p& I
If ReportFolderStatus(Folderspec) = 1 Then
' N, }! a3 ^- |- s5 K/ icreateFolderDemo = -1
2 S' e0 F6 |" O, H0 GElse ' v! P& H Y. P; I0 S, x
Set f = objFSO.createFolder(FolderName) 2 X" s+ q+ k; c' Y# |: x
createFolderDemo = 1 " e# v% H7 @+ ^
End if 2 B; Q# Y% `; s" U* |: t* [; |
End Function
6 e! {; @1 \; s; {; q
F; q g! z. j" _) Y( L'目录删除
" i J: b% p5 d G& R! U: {8 wPublic Function deleteAFolder(Folderspec)
& V1 A- f3 ]0 g& {Response.write Folderspec
. h4 q/ x; b8 B* ?" k' bIf ReportFolderStatus(Folderspec) = 1 Then
' I! g6 _# ?, `, }objFSO.deleteFolder (Folderspec)
; s5 h9 Y8 I n' @: g/ B3 KdeleteAFolder = 1 0 Z. B$ S) W; q9 U! b+ h( c
Else , o6 j5 v' j/ @+ V
deleteAFolder = -1 $ z) _+ `! B! z6 r. N% B+ f. s& A
End if 9 q9 s* y, R/ g5 f* G7 b
End Function
& {1 J( \+ `# C* x9 F4 N Q
) Y7 u! _/ u( I3 W- x7 J1 I'显示目录列表
) t8 K) {) y8 ]' wPublic Function ShowFolderList(FolderSpec) 8 p+ Q& ?: S4 I5 }1 ?5 S
Dim f, f1, fc, s , T) q) Q" j6 f6 X
If ReportFolderStatus(FolderSpec) = 1 Then 7 {7 x0 W" C! A# x e5 i8 x$ x
Set f = objFSO.GetFolder(FolderSpec)
" ^( z1 T0 j Z8 kSet fc = f.SubFolders
# j; Y8 b, R8 U1 o: b5 {For Each f1 in fc
7 O5 x. t; \; A) }s = s & f1.name ) R( X; \) ^' i
s = s & "|"
5 g. {, Z5 n: ENext ( `7 U! B- |# s
ShowFolderList = s
4 P+ }4 h4 {- o* w1 F$ s0 I9 vElse
) q; }4 r1 h2 q0 DShowFolderList = -1
( \" y4 Z/ C$ }( @& rEnd if : W8 _) s2 T9 M5 _! ~* x. G
End Function
! j Q: r" B$ L7 Y' ]0 P& n ~& H6 @& I, ?
'目录复制 , E S) Q! t+ p8 h) g7 {
Public Function CopyAFolder(SourceFolder,DestinationFolder) * @7 D/ E+ ]7 A% {& Z @
objFSO.CopyFolder SourceFolder,DestinationFolder 3 Z* M1 x# ?5 N4 s! H7 t
CopyAFolder = 1 & i# J8 i! p( Q- q) T1 z' I# p: h; d
CopyAFolder = -1
1 [( |0 f8 M8 e# {, a# CEnd Function
* ?" o, P" i, C/ _* D$ f$ x) g
& l$ s2 B! q7 r" W) i4 d: n1 U& y$ f' I! Y7 ]/ l0 d
'目录进行移动 9 \5 l# Z% L7 O. L6 f
Public Function MoveAFolder(SourcePath,DestinationPath) + r; t. w$ c7 b6 o- ]
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
o* K4 k. f) J1 L9 A. oobjFSO.MoveFolder SourcePath, DestinationPath
) y0 Y: Z4 H& ~2 N! eMoveAFolder = 1 5 L/ E0 |$ N% l# H' o, p
Else , @, l9 i& `( R6 N5 V Y5 N
MoveAFolder = -1
8 M h* r+ h2 I+ JEnd if 7 Q# x5 l, h1 I3 P4 d
End Function
# @& V0 C' V9 {1 y8 g$ w7 h* O- W2 F7 L9 F
'判断目录是否存在
4 h1 {6 \. J! y2 u0 S* {, P3 U2 BPublic Function ReportFolderStatus(fldr)
5 B$ [+ q0 D. `3 Y& g7 k7 }Dim msg
+ _ c5 q* `/ D1 U) q7 hmsg = -1
( d0 c$ W7 Z2 H2 {% rIf (objFSO.FolderExists(fldr)) Then
; ` \" B3 x; x- o, l: @msg = 1 , y( U8 m6 E& i4 o2 j
Else ( M+ _+ u3 @8 c. E p
msg = -1 0 l: u, E. O, z) |
End If
) e6 l( C2 P* Q1 s$ I0 oReportFolderStatus = msg " Z) u! D/ c7 c/ f3 h9 U
End Function @) X( i w8 j
$ z+ `- W1 w6 I! A6 B @% e- J
'目录创建时信息 8 E1 Y) A' Z7 M; b
Public Function ShowFolderAccessInfo(FolderName,InfoType) & @' X1 [2 {9 u- p
'//功能:显示目录创建时信息 , _5 i, `) _; }( A9 [
'//形参:目录名,信息类别
3 J* B9 t. @1 p'// 1 -----创建时间
9 W; \) m. D4 |' R, r'// 2 -----上次访问时间
! N0 v) H9 w6 r& K, ]'// 3 -----上次修改时间 ; s( t' f2 ]( y5 ?
'// 4 -----目录路径 a: ~ I* s2 D$ I% D _
'// 5 -----目录名称
q8 d* Q+ A2 N. T8 N'// 6 -----目录类型 8 D0 f4 x4 M# y8 j/ T4 Q# d
'// 7 -----目录大小 $ h. \8 J- n9 y4 |$ w1 k
'// 8 -----父目录
, C2 ^& r4 s( w8 ~'// 9 -----根目录
- W5 f9 r9 J. C7 f+ MDim f, s . T6 x- G1 q2 x( G8 ~, I) ~. M
If ReportFolderStatus(FolderName) = 1 then ; e V/ E4 Z, b! n$ `7 C3 ^
Set f = objFSO.GetFolder(FolderName)
6 G$ ~# j5 a, K) z( t5 Gselect Case InfoType 5 i' n2 D; C0 W1 K- ]$ l
Case 1 s = f.Datecreated
7 B3 [5 E" i8 y5 w* i; S2 ECase 2 s = f.DateLastAccessed % l$ M( \( y! A1 K) p
Case 3 s = f.DateLastModified 4 z) f; F2 B& d' K
Case 4 s = f.Path
2 h! S6 S; X; q( Y2 [) X& n5 RCase 5 s = f.Name
& b5 G( Y+ I# ?9 hCase 6 s = f.Type
8 R- f- }- u$ H( X( CCase 7 s = f.Size 6 j. z9 G# d/ v/ C2 I; H8 `
Case 8 s = f.ParentFolder
7 H: W T7 m' d, m& b% f! n/ ~Case 9 s = f.RootFolder 1 T. ^0 h/ F$ _: F. i# W" d
End select 3 u, o8 u2 ^& P" B r# Z4 O8 n! V2 @
ShowFolderAccessInfo = s
+ x* B& g$ t3 d0 _2 `/ FELse 9 D) C: ]# r/ j! l2 `! G4 @# u9 V- C6 X
ShowFolderAccessInfo = -1 - t, w& W7 i+ Q4 d m c6 P
End if
2 W9 y8 ^: f6 u% V# i4 gEnd Function 1 } g% e" Z/ d# x; \
- K1 l' W4 `& d2 k( p" K4 ~; B
'遍历目录 & O) S" {. [( j! D" m% b
Public Function DisplayLevelDepth(pathspec) ( @: ]% p" s) w: }
Dim f, n ,Path ( Y3 j( a3 \/ f0 c0 Q, R7 o0 k* _! j
Set f = objFSO.GetFolder(pathspec) 4 Y3 I: Y' s! U! p
If f.IsRootFolder Then
( i% h3 b: v; J2 ADisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
+ p$ u" v6 T% \Else C l' q( o/ c$ n, P) ^
Do Until f.IsRootFolder ! {" w, w5 n4 c1 W( h7 g
Path = Path & f.Name &"<br>" 1 ^: Q2 ?1 ?9 f
Set f = f.ParentFolder
. Z7 ^6 C' J' q- W0 ?n = n + 1 7 b' H* Q/ h! n7 g
Loop 8 }# A& _2 t H, i- b9 h+ i
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path ) u" ~$ F- O2 Y7 w& {& T
End If & f5 `/ @# B3 P: Q: g
End Function % J7 I8 p; R7 `( D
- W7 M7 n+ z4 B& y& t'========磁盘操作======== ) {7 J+ i v2 }* \4 u4 S
'驱动器是否存在?
! U- R# [# f4 d1 T7 A+ j" fPublic Function ReportDriveStatus(drv) / A' j7 E9 {& p
Dim msg ! k9 p& Y0 i1 [) A6 v, v4 z
msg = -1
1 S$ R. Q+ {+ }! mIf objFSO.DriveExists(drv) Then 6 [- w9 j8 G, x% X
msg = 1 $ |0 v5 y5 v8 S6 b
Else
( X6 @. K- m) [+ U9 Y4 |msg = -1
: W$ b+ o/ L$ J. K) h. YEnd If " n# t- ~" G3 e" C
ReportDriveStatus = msg
/ N! b7 o1 T8 p0 lEnd Function
8 @. }2 H4 [3 L0 Z6 Z# O$ H3 X: [9 J1 M
$ i; T- t8 K H- H) R% ?6 D'可用的返回类型包括 FAT、NTFS 和 CDFS。 " C3 R+ v% V. P; P- P* Q% |
Public Function ShowFileSystemType(drvspec) / X+ U* y! U: @+ _8 P
Dim d & f4 c# }7 V5 h* I
If ReportDriveStatus(drvspec) = 1 Then
+ ^4 d& U- Y7 q; K- |Set d = objFSO.GetDrive(drvspec) 2 Z: f* d' N, Y# M
ShowFileSystemType = d.FileSystem
/ Q2 i+ b( x/ k: o' g! ?ELse , \: G3 X' } S4 P- g, P( A, O0 x
ShowFileSystemType = -1
: ]* }7 b: p2 I. J% R: hEnd if 5 l8 J0 E( Z" o8 A
End Function
5 y( \5 F3 L; E4 r1 ?/ d' B7 TEnd Class 2 p; C' [$ G+ _2 D O7 d6 y K
%> |
|