【高州情】高州人深圳站

 找回密码
 立即加入
查看: 715|回复: 0
打印 上一主题 下一主题

ASP文件操作大全 [复制链接]

管理员

论坛测试[砖]家

Rank: 12Rank: 12Rank: 12Rank: 12

金币
7319
贡献
615
威望
9151
最后登录
2026-10-4
帖子
1876
积分
25897
UID
10

论坛元老 网络高手 新人进步奖

跳转到指定楼层
1楼
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全# I5 n: t2 M8 _6 S# O8 a. d
<% # Z3 k( q$ N, y% |0 g: {
Class Cls_FSO 4 K9 _7 z. |2 P$ a! F
Public objFSO
+ I( z* n& i+ a6 r& ?+ M3 {Private Sub Class_Initialize() ; ~1 u8 S% U' e4 Y# p, l( C8 t* b. c
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") + \1 ]7 {9 Q! K+ K2 {! W$ _
End Sub
, i) |- G: Y- T5 IPrivate Sub class_terminate() $ o" o% |" C1 C9 N9 l  f6 F1 t! ]
Set objFSO = Nothing 0 k1 g7 D% ~# M3 Z% K
End Sub
2 N8 x5 j$ z1 u" \$ l: q7 ?4 g/ D& l- j, K+ T2 t
'=======文件操作======== 7 L& q$ F6 }+ e, u% L6 _5 o1 q4 v
'取文件大小
& P7 @$ T- ^- l, XPublic Function GetFileSize(FileName) ! d4 f& {+ b1 X" p2 C# J/ C
Dim f
8 \$ E4 W5 ^; X1 k* pIf ReportFileStatus(FileName) = 1 Then
( W" y' x1 K7 h, _( G% ~. [Set f = objFSO.Getfile(FileName)
4 y" B4 B: E5 uGetFileSize = f.Size
7 k/ T: j2 E  C( ^- w! t9 kElse $ y( T$ T" {' ?; P  K) Y: v& f
GetFileSize = -1
% Z  o2 Y8 t- SEnd if 5 ]0 V9 a; G2 j& p4 D
End Function ) ~, h! m* j! W  E! H! ?
. ?; ]+ G7 h" U: h$ w$ c
'文件删除
7 i9 A' p! H: k& n  ]Public Function deleteAFile(FileSpec) , U/ X, A% t; h. L
If ReportFileStatus(FileSpec) = 1 Then
! g( G/ I( h! {5 ?objFSO.deleteFile(FileSpec) " l7 d! o1 p2 r2 L
deleteAFile = 1 7 Z9 ^. b) [3 `3 }' I. J* Q1 m
Else , @  A8 _, Y' Z2 p* U0 [
deleteAFile = -1
. V: t' N3 h% v3 b# o7 wEnd if
8 y! }! X4 i* }End Function 5 Z2 m+ L$ q* J! S5 U: I% i# A

" i" _" T9 S1 F% g'显示文件列表
) q! m6 D; g. Q  RPublic Function ShowFileList(FolderSpec)
! i0 \8 A6 V' ]Dim f, f1, fc, s
1 x, _! G9 H  z& t1 E! a% u$ ]If ReportFolderStatus(FolderSpec) = 1 Then
# R: }# h- y, j- q0 s! T0 fSet f = objFSO.GetFolder(FolderSpec) ) I  i" V% U5 @
Set fc = f.Files : {9 h. C& F& R" ^, M
For Each f1 in fc
# [2 ~+ g' W. G: v* @- j' D7 ^s = s & f1.name
' \9 J! S$ o4 h. y) W2 vs = s & "|"
  w' f7 @. V7 ]7 I6 p" K' PNext
3 a( _& p9 z) F. PShowFileList = s & A) m: r6 F' m$ ~  z5 U
Else 1 y  Z- r0 e1 X& v# V8 n
ShowFileList = -1 ! \. D6 l9 b) P' g, _& G3 \
End if 2 U3 J% p: ~( `9 J" m
End Function
$ V/ S! g! e( B! @+ z6 m2 B
" U  f. b- L) \4 ['文件复制
% y; ?! H1 S% P$ nPublic Function CopyAFile(SourceFile, DestinationFile) " {% c5 w1 m4 B" A7 E
Dim MyFile 8 P1 H9 k' h/ @, ^( P
If ReportFileStatus(SourceFile) = 1 Then
& g/ V& M- z) U2 }: W' B6 l' _0 Q# oSet MyFile = objFSO.GetFile(SourceFile) - |/ s8 k3 T, F$ N8 f# A0 M2 Q
MyFile.Copy (DestinationFile)
( G2 {  e1 R# y' {CopyAFile = 1
; C4 m9 b' ?" nElse 3 Q# t' l8 S7 z7 V' R# t
CopyAFile = -1
; ]6 u  i8 L- E% w5 T* rEnd if 3 y" [) G2 @0 D- O
End Function . {7 Y; R# z" U- a4 R

7 S) j8 m9 y7 N8 M7 D'文件移动 ( n# }' E# e% K
Public Function MoveAFile(SourceFile,DestinationFile) 3 \! J/ w) e$ z" k0 |
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then   q+ |% P5 g  @% M  H: d" N4 k2 i
objFSO.MoveFile SourceFile,DestinationFileORPath
4 N* s- G5 \5 f$ N: b4 KMoveAFile = 1 4 p9 ~" S- L- j3 Q
Else " a4 W, r3 p9 v- s
MoveAFile = -1
. l4 c6 t% _" Q. pEnd if 0 I4 \) _+ X4 L" u1 v
End Function ; [5 ^$ x) t9 I" J
* t, H& ?8 D5 z8 X; ^
'文件是否存在? 4 O/ j6 s! A+ Y" Q5 P
Public Function ReportFileStatus(FileName)
; `2 Z* X% A3 |2 y6 e/ O- yDim msg
% |# g! x: ]2 O5 [( Q/ s! Umsg = -1 5 d5 M* b7 s& K! l1 a& N' d/ B
If (objFSO.FileExists(FileName)) Then
9 n: e: x: ~( ^6 [- W6 E" ?; V1 k* f$ ~msg = 1 " T; e: f8 k6 T& o
Else
0 z2 O4 }* ~, ^  ~; jmsg = -1 ' k0 b) p/ m& F  T, ]9 H, U' W' ^
End If
. `; J4 G* X! z, z6 K6 hReportFileStatus = msg 8 g8 M; p# `8 h# z, W1 h9 _
End Function
4 P. C3 p: q6 N; A6 J9 ^/ F& a7 B0 K1 P; v5 N
'文件创建日期 . l, _% ?5 M6 t7 g2 d$ E4 u. y
Public Function ShowDatecreated(FileSpec) & m4 J/ B! h3 z* Q
Dim f ! \9 y0 c; |) d4 ~8 C5 r
If ReportFileStatus(FileSpec) = 1 Then
  w, f5 d" `- Y' I0 l& n3 t& ?! ~. e  _Set f = objFSO.GetFile(FileSpec) 3 z+ {7 D: Z( q  L
ShowDatecreated = f.Datecreated   f* }* Q0 `8 y; J! ~8 h& V$ `# ]7 l
Else
' F5 ~% \* [( y+ U" a" U& {ShowDatecreated = -1 & a6 _- c% H2 \- E8 i  A
End if
  a" a8 y& Z; t1 D- k* nEnd Function , @+ B2 q( J# q) @8 w

. z1 B& h- E, o" m'文件属性
( s- X6 V8 E5 [( y( ^+ X7 r. z! VPublic Function GetAttributes(FileName) , M( Y" S7 R# t2 n
Dim f " B5 i! u( z" J5 C. b  v: E
Dim strFileAttributes 0 g* V) F; n& h, N1 G6 U
If ReportFileStatus(FileName) = 1 Then
8 j- ^- v/ f3 y+ z, ~. uSet f = objFSO.GetFile(FileName) 7 k& b( |' R% ]- n5 P
select Case f.attributes
/ ?$ A* o3 H* X8 x2 G6 k( KCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " 4 `, W+ J$ r* l- f6 ~
Case 1 strFileAttributes = "只读文件。可读写。 " 5 w; _: d9 ?( ^
Case 2 strFileAttributes = "隐藏文件。可读写。 "
* N4 \! X  e. F  A4 J' |Case 4 strFileAttributes = "系统文件。可读写。 " & j3 x+ ?' c2 n6 p5 `  y  F! h$ a
Case 16 strFileAttributes = "文件夹或目录。只读。 "
# Z4 Y% b* l( K! G/ M  TCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " ) A  k0 K8 r+ C/ d
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
2 U& f! T- ~. H/ fCase 2048 strFileAttributes = " 压缩文件。只读。"
4 E( k. E- D& H' z/ B' KEnd select ' {9 U$ a; o: V+ K
GetAttributes = strFileAttributes
9 o, u6 i; C4 C  tElse
. {1 {, A  a% v- zGetAttributes = -1 % M4 C- T1 u8 }4 |& n/ D* f
End if 7 e9 b7 r: e/ |; U# X
End Function
4 h8 K7 v( S+ i+ t4 X: \
! d. w5 H: a& n! a'最后一次访问/最后一次修改时间
- [% E: o& f7 w1 o" H! EPublic Function ShowFileAccessInfo(FileName,InfoType)
" K2 |! A# T; p'//功能:显示文件创建时信息 ( K0 o2 N. V: C4 J- J5 t4 q2 U
'//形参:文件名,信息类别
5 f# Q% A& N! s7 e7 M3 R'// 1 -----创建时间
4 z% d! O+ v: F9 P9 o'// 2 -----上次访问时间 3 v* M+ ^: u  J7 a, ^$ H+ P
'// 3 -----上次修改时间
6 B7 R) ]% U( D1 H0 j' t'// 4 -----文件路径
% s& t( F3 }/ S2 M'// 5 -----文件名称 2 R0 I! l# [; ?' {' ]3 j& w
'// 6 -----文件类型 ) u2 r( c- j1 o* _3 k4 s
'// 7 -----文件大小 ( m: F% E. O0 p6 g. I# a4 F2 l
'// 8 -----父目录
: I- l3 ]# d, P2 _- l'// 9 -----根目录 * g0 [/ V" J+ G
Dim f, s
: Z+ D- ?5 }7 iIf ReportFileStatus(FileName) = 1 then 7 y; a  @: i7 w* P' ^- |
Set f = objFSO.GetFile(FileName)
, L1 k8 B# N: h1 j7 |select Case InfoType - f0 v- [9 x* {8 s! J% h8 G
Case 1 s = f.Datecreated 2 S: r! N9 W7 J+ V
Case 2 s = f.DateLastAccessed , y# r# F% j& o) }  _5 S6 D
Case 3 s = f.DateLastModified
( l7 d# z5 l' `9 t  L1 d1 |Case 4 s = f.Path
2 ~, P( W+ o4 i: ^8 PCase 5 s = f.Name
2 I" Y/ f1 J( S: y" @( {: Y- f- K% oCase 6 s = f.Type
) J6 W. W& I- o6 uCase 7 s = f.Size / N$ Z; l  H4 {
Case 8 s = f.ParentFolder 3 ]0 g$ H6 @. ~% A/ t/ ]" i9 F
Case 9 s = f.RootFolder / c  J2 }" B9 z( f
End select : c' O% P' F. B! s. p
ShowFileAccessInfo = s
5 ?% U" P  H3 \( DELse
6 q% q! k6 y# \) G$ E1 H6 Q, NShowFileAccessInfo = -1 . \% }, R% q" V7 b% Z/ h
End if
# h' L# S5 Z9 h7 kEnd Function
' X( d) a( w; Y# Q7 j& ^' F4 _: H# S7 g9 L/ E3 i) s5 I; t+ B
'写文本文件
8 [" `, s8 Q$ g( ^/ EPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) 6 \; v) n* \1 @/ i0 ]+ }* W+ T
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 0 K3 X+ G: A/ I: N0 t$ r* m' ^
Dim f, m 3 }: Y* h: s& M# U( D7 }  s
select Case WriteORAppendType
8 \" q3 s8 [6 q% PCase 1: '文件进行写操作
! ?6 F% E3 v4 \( P" T0 ASet f = objFSO.OpenTextFile(FileName, ForWriting, True)
* j' [' X* v) l) pf.Write TextStr : p. q9 ^2 @- U7 _$ r( y
f.Close $ L+ @4 ^; a( u( ~; A( K3 A! n
If ReportFileStatus(FileName) = 1 then $ P7 b% _9 W: I. J% k( ^
WriteTxtFile = 1 + B! F2 A3 r2 }6 F4 |8 j
Else " S8 W" ]0 v0 a4 w9 G. X
WriteTxtFile = -1
& A; g& Z; S# c* d% X) A0 VEnd if $ e/ q* ~6 Z+ n% W0 {0 ~$ Y* u
Case 2: '文件末尾进行写操作
" l& g# a6 A- [" I* V  IIf ReportFileStatus(FileName) = 1 then
  r. A1 [: }9 Q6 P) JSet f = objFSO.OpenTextFile(FileName, ForAppending)
# p" i0 I( l  p+ u8 a. Qf.Write TextStr ( t3 i1 }% @' A$ _# s8 _8 I
f.Close
2 _9 q9 s8 O" G  t/ D3 oWriteTxtFile = 1 . l$ A( Y8 ]  c* C& V0 Y
Else
1 {6 y* F( K7 G6 \1 hWriteTxtFile = -1 ! j8 o3 e: Y2 Y4 Y
End if   B( q7 y2 S* q3 u& ]* @
End select ' ]" G3 K) l$ ?; u0 l1 J' c. i
End Function   ]' L  u' T* D' x; g& f' X

" [  Y: G0 _  ?. J+ e4 y'读文本文件
9 Q0 s( X' }( k2 f3 g9 ^Public Function ReadTxtFile(FileName) 9 c, f& w* X; {+ S  p4 ^& i
Const ForReading = 1, ForWriting = 2
/ L# O- \* Q0 _  \1 k' UDim f, m 8 Z- s' t. t/ ^  H0 V& E( O( P
If ReportFileStatus(FileName) = 1 then + z6 L* W$ s8 \$ E% x3 f9 A4 K5 d: N
Set f = objFSO.OpenTextFile(FileName, ForReading) , d# V, C0 }6 j" ]8 O% L3 T$ ]
m = f.ReadLine 4 E3 J) N) o+ t6 H
ReadTxtFile = m
! t8 ^' w( `' y' B# Af.Close
) t0 x3 {% m/ Q* _$ N$ z0 k. m2 E  _6 vElse ( E! L8 X/ u- l7 p- X5 Q+ K
ReadTxtFile = -1
  U$ n# z+ G  T5 T5 {9 o) YEnd if , x1 b' Q1 {3 d' D4 ]; t" A- j8 T
End Function
3 E' w6 d  S. I. p7 r
6 ~+ e7 O- Q. |" l'建立文本文件 ! A9 y, k6 ~6 I5 `) R& c) `) I' F

9 h6 ^2 ?& H4 v9 M7 L/ H'=======目录操作======== + g; p: X" W6 Z9 G& Z
'取目录大小
- v3 j' ^# C9 U1 mPublic Function GetFolderSize(FolderName)
8 E# H( N9 O* \! q2 GDim f ) Z1 i3 ?2 g9 R
If ReportFolderStatus(FolderName) = 1 Then
$ S- C- p: e) b% @& y& u! e- @( tSet f = objFSO.GetFolder(FolderName)
7 b% D" S' \/ ]& }1 [6 a7 H/ T( q, eGetFolderSize = f.Size
7 A$ s" V' z& EElse 3 j. S: _4 x* n2 U7 `8 M  K
GetFolderSize = -1 6 d  r6 `' O4 y% c$ g) U" d
End if & c+ x/ M: x% |7 y7 I
End Function : ?) c9 J1 s& G. B! Q& a
, \2 _; d4 d0 n" I& k! e
'创建的文件夹
* x5 S) I3 B- x% a: OPublic Function createFolderDemo(FolderName)
7 ^8 R% H0 {& ^0 c& yDim f
. w4 R# q7 A+ p* o0 G8 K* u+ kIf ReportFolderStatus(Folderspec) = 1 Then
+ i  o- k: ~7 M) fcreateFolderDemo = -1 ! X+ k; ~. P+ g/ q( o7 g) \+ v
Else ( d1 ?+ L0 Q7 G2 {
Set f = objFSO.createFolder(FolderName) ; z  s5 w0 e, O& J  \7 V
createFolderDemo = 1 8 c9 P) }% V2 K# L! ?
End if
  @, I% g. `7 H6 g: q& K6 ]4 REnd Function
- D% y' N: J* m& S8 e& P
! i1 p( a; L$ P7 e- f, q/ Z6 b& `'目录删除
$ V0 O- s, `+ S1 h7 x$ FPublic Function deleteAFolder(Folderspec)
# `( w5 O5 z% vResponse.write Folderspec
6 ]9 C1 k  i0 o) c5 TIf ReportFolderStatus(Folderspec) = 1 Then " A; |# n3 P. f: Z( w- r' v
objFSO.deleteFolder (Folderspec)
7 ~) a( k$ E* RdeleteAFolder = 1 8 Y4 Y7 U; h0 l
Else ( a, r3 \! w. x
deleteAFolder = -1   v# r+ i3 S1 \5 i. e) R, v
End if ) T$ U; R6 W) y" S) f4 z9 h
End Function 7 f- Q3 _. k% J/ d& i5 K8 Q

' d7 P& n8 j6 D- [) r'显示目录列表 " _% @' D1 L( g4 ^  z& @& @. C' x& \
Public Function ShowFolderList(FolderSpec)
! ?; q- \0 G& |, g! oDim f, f1, fc, s 4 |8 Q% B3 {4 I
If ReportFolderStatus(FolderSpec) = 1 Then $ z+ `* p6 h) i
Set f = objFSO.GetFolder(FolderSpec)
* L+ x2 P$ e' {& N$ fSet fc = f.SubFolders % J* l* K! Q6 X4 ~8 X$ C0 b
For Each f1 in fc
$ D% N" H1 @2 j* S: z, Vs = s & f1.name , J& j- ^% ]' [; Q1 `
s = s & "|" 7 K( N# b3 d. E: C
Next
& A$ B/ _/ q) X) N  _! lShowFolderList = s
9 ?+ v, E/ v# l- V* }( h: vElse
) a7 T4 B2 J9 t. Z) j  U, b; CShowFolderList = -1 - _6 k5 N$ @" f. s  X+ r3 N3 w
End if
! h$ y0 i8 `0 r2 Y3 }# eEnd Function
( A( Z* L, A+ q6 n" g1 i9 r, \- p7 L3 y  s) V8 b
'目录复制
% I" |( F+ N- d! g* ^# s# @Public Function CopyAFolder(SourceFolder,DestinationFolder) 4 }, q( q8 s3 ]0 w; f& R
objFSO.CopyFolder SourceFolder,DestinationFolder , `2 T4 s' v" d; v% [
CopyAFolder = 1 5 Y3 f7 C3 v6 V9 K; `; `
CopyAFolder = -1 / E+ }/ R" z9 m; B# w0 m7 N$ S" E$ _. [& l
End Function
: g3 i; p/ C; Z. m/ [( W! v3 j$ C1 J) B" ]+ J1 O. G4 G! q
- s. G( Z8 L3 |5 _. M3 X/ S, [
'目录进行移动 # t- D% y% g# H8 z0 h
Public Function MoveAFolder(SourcePath,DestinationPath) 4 D, L  X( @( H4 a8 f
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then ' W1 ]3 d5 K- [
objFSO.MoveFolder SourcePath, DestinationPath 9 y) W; [8 j  g2 v
MoveAFolder = 1 ) V& t/ A- w! N# @. a; L- A
Else
1 J& o9 L$ w; Y: O3 Q6 A/ iMoveAFolder = -1
! W, W8 @/ F& J' e  h) R" BEnd if
( K& J" |6 S* r& tEnd Function
4 [$ l4 b/ w5 ]1 g
, Y/ Z9 }( D/ k% p/ _& J5 j'判断目录是否存在 $ Y( U5 W$ e& ~
Public Function ReportFolderStatus(fldr) * Q4 O) o! n4 U/ ]) R
Dim msg
" Y! B, P) }4 xmsg = -1
0 b  K" R4 U7 W. HIf (objFSO.FolderExists(fldr)) Then
; [% K( R3 n5 e+ y  E: gmsg = 1
6 O5 V4 v) V4 z% X: u6 _! h$ [Else
. e0 Z  r0 i  ?! a% Tmsg = -1
0 K, r8 H" Q) z# e1 c8 U$ G/ oEnd If 2 s  }& O- `8 u2 M
ReportFolderStatus = msg * H8 M/ G# j/ K+ _2 i9 R1 x
End Function ( C, i* z2 R* i3 ~) b
& r, r: z, |1 V3 Z3 T
'目录创建时信息
5 [; U5 J  u! i4 N9 R* v5 _8 QPublic Function ShowFolderAccessInfo(FolderName,InfoType)
( a; O& |! z! j7 F'//功能:显示目录创建时信息
. S  b8 Z1 i' W4 V% n'//形参:目录名,信息类别
% \7 P$ [4 n! S% d3 L. C( w3 _'// 1 -----创建时间 # B  v  @( s2 J8 A$ z
'// 2 -----上次访问时间
: q9 i5 w% |  h) _' t'// 3 -----上次修改时间
3 {2 y1 t' ?; p+ ~/ z'// 4 -----目录路径
- r7 _9 }% }+ @; T( E% X'// 5 -----目录名称
; o2 e" \6 c9 J1 b, i'// 6 -----目录类型
; N+ ^  V2 x" H* D( f( y7 Q! x'// 7 -----目录大小 + q; k. R, n. k
'// 8 -----父目录 $ w$ h3 u, ^$ ]3 ~1 A4 [( l3 i
'// 9 -----根目录
9 p5 A" W, p4 ]5 g; L3 n, {Dim f, s + }* w$ p5 y  \+ S6 |% X9 D9 \
If ReportFolderStatus(FolderName) = 1 then / T) z  y4 S. A. Y7 T
Set f = objFSO.GetFolder(FolderName)
, |9 [  a$ c+ i# G* gselect Case InfoType
# k! Q% F5 P6 MCase 1 s = f.Datecreated ! o8 u+ Y5 F5 a  o$ z
Case 2 s = f.DateLastAccessed
1 h2 ^3 M) h0 g3 D! ]Case 3 s = f.DateLastModified
# K# B4 v7 a, H; q' D* t8 ACase 4 s = f.Path
$ x: F, b( k2 H9 u" H( }Case 5 s = f.Name ) {% l1 V& @" I0 K8 _2 o
Case 6 s = f.Type ) P% d: |: h) b
Case 7 s = f.Size
  C" a, s0 H: c2 W% bCase 8 s = f.ParentFolder
9 ]. Z5 G) @$ I6 ICase 9 s = f.RootFolder 5 H* l: J& L/ k6 p! o; S
End select
0 \& B6 t. K  Z8 X( u/ O) hShowFolderAccessInfo = s
) N: E" p/ h0 |1 D4 [0 dELse
' s  O% B) H' m: L+ cShowFolderAccessInfo = -1 # b. f' i: {% g: X0 k: J
End if
/ S) f4 c4 J  ]% O5 J7 f4 P* u  sEnd Function 5 {  F$ n9 T" s4 T3 n+ b! F& O2 V

& u4 `; Q0 E4 s! W# D& s'遍历目录 8 G, g0 o+ T5 L2 X/ J6 e
Public Function DisplayLevelDepth(pathspec)
1 c/ c3 T8 e9 lDim f, n ,Path
4 I, h4 |7 Y; g8 Q4 w7 t# rSet f = objFSO.GetFolder(pathspec)
6 V& H; ~1 k! F) S1 sIf f.IsRootFolder Then
+ b% f$ \* ]! ?5 q  O2 uDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder , n# x- G% o) b+ \
Else ! Q' y. H/ X" z; o! {& K
Do Until f.IsRootFolder
' F& T5 E: j8 J: s; O5 g: X) F9 R4 ?Path = Path & f.Name &"<br>" ( s% N! e1 F1 m) _
Set f = f.ParentFolder
8 Y& U1 |& d- T9 s5 a; [$ [n = n + 1
5 u5 W9 l+ f( w' K! lLoop
2 e: n7 Q1 D* K0 g* n2 S& P. ?DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
' E/ Q, a. m/ c. k) XEnd If
# {; x. N& L! S2 t# W7 B& IEnd Function
+ I% j# I  U3 J2 d2 F9 H
2 t9 M( R: `, w1 p'========磁盘操作======== + b8 X: |5 I9 j, V/ I2 f
'驱动器是否存在? ! p+ c! ~1 y. z( T7 v
Public Function ReportDriveStatus(drv) & E" G  ?8 e8 _& L6 j& g. }
Dim msg
# ]* I) S0 C+ i2 |* ^5 Bmsg = -1
) o' {- Y2 E$ l* k& B+ k  z8 M  hIf objFSO.DriveExists(drv) Then ; ~3 N- ~5 c. a8 E% R; B5 \1 g
msg = 1 ! ]( @. ^' t% y9 `
Else
! X. Q. {( J: {! `msg = -1
6 ]+ a& [' \* j$ v% d7 s) NEnd If
/ i& p8 C) n$ ]9 V+ oReportDriveStatus = msg " c+ y9 I6 |6 L5 ]4 _
End Function
' y% I8 f0 W( U- [$ J" Y' r1 g! X' k8 J$ ^+ U
'可用的返回类型包括 FAT、NTFS 和 CDFS。 $ Z9 n, Z0 p# S6 ^( R; V, T! O
Public Function ShowFileSystemType(drvspec) 2 L( }7 m- v- r: F& q7 ^( K
Dim d % u+ [* ]6 a" v  J, |& E. A
If ReportDriveStatus(drvspec) = 1 Then
" u# X! k2 W- Q+ DSet d = objFSO.GetDrive(drvspec)
9 m) C3 R2 D1 o% ?$ NShowFileSystemType = d.FileSystem
8 p, i0 D; X& P6 wELse
" i2 S1 U. F7 e( I" ?; K0 k+ lShowFileSystemType = -1 , z. C& L7 _9 |
End if 0 K9 R( ?( G  Q! |+ h$ J6 t
End Function 7 ~3 N& i. q! I$ L  f) j5 L' v
End Class
# T+ f$ n0 \2 X%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

【情系根子】〓 https://525247.net 〓

个人业余电台:BI7ILX   守候频率:1343212JJ08
您需要登录后才可以回帖 登录 | 立即加入

Archiver|手机版|高州人深圳站

GMT+8, 2026-11-7 02:19 , Processed in 0.027325 second(s), 13 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部