【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

金币
7316
贡献
615
威望
9151
最后登录
2026-8-24
帖子
1875
积分
25896
UID
10

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

跳转到指定楼层
1
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全- H9 w+ p) X# X) ^
<% ; b. p. M; r3 y/ K; l& e% ^
Class Cls_FSO
) u" m7 a6 c4 C. X" X+ o6 fPublic objFSO
6 G) L5 l6 l" o8 Y% H' l, QPrivate Sub Class_Initialize() 5 \2 y% Q/ i- Q1 ~0 u, V( d5 t' R
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  R3 ^2 I2 A, g; W6 PEnd Sub
$ l& e. Y% t$ p) R' c6 M. ^/ HPrivate Sub class_terminate()
+ u8 q0 ]- k2 _3 k. o7 I4 F: I0 mSet objFSO = Nothing
7 Y( C6 R- R: HEnd Sub * K, Z( H$ {8 M4 z/ |& k
! c. A5 I9 @" l5 ^- F, h7 p
'=======文件操作========
& T7 k9 g) ]: b/ R& l# i'取文件大小
/ H; N, X9 D6 u, }* a+ u+ H2 v3 E% mPublic Function GetFileSize(FileName)
1 A% N+ c$ F3 ^( V3 q' vDim f
  i1 Y1 \3 }. o8 K7 d7 CIf ReportFileStatus(FileName) = 1 Then 9 X& [5 m- G' X; U
Set f = objFSO.Getfile(FileName)
, D0 t+ r$ @# `$ a7 AGetFileSize = f.Size
/ `# {; M1 `1 q2 xElse
( P; U: \, i" ]% uGetFileSize = -1
  w+ ~; c, h" R4 r5 [5 TEnd if ; T: N2 q8 d7 x$ s  B4 P
End Function 9 W/ F/ {: V% b4 d/ d! N5 ]% M5 l

  W) T: X$ k* [1 K; F'文件删除
4 G' {4 t; @5 YPublic Function deleteAFile(FileSpec) 8 Z5 y4 |* H7 E9 i) k* Q
If ReportFileStatus(FileSpec) = 1 Then 0 k6 A$ e. i, ?! s" V) Z# j# p
objFSO.deleteFile(FileSpec) 3 l& {; E1 k( w( I
deleteAFile = 1
5 u. \, C( S$ k) h  m+ jElse
1 Z, ?0 @( m7 B" a; I/ B1 AdeleteAFile = -1
. w( a* b$ r. s9 x( F( x. |End if   ]4 c/ `' v3 N
End Function
* q" d+ d- b. i, ?8 w$ B5 Y
3 R+ s  F8 m$ a'显示文件列表 # d8 R9 C5 p* t0 B
Public Function ShowFileList(FolderSpec) % e! e; v; J# Y/ |
Dim f, f1, fc, s ) }% m9 R% C2 U9 E8 b6 N# R5 }
If ReportFolderStatus(FolderSpec) = 1 Then
) I" N* P9 v1 d" XSet f = objFSO.GetFolder(FolderSpec) / u4 A; r; _# ~7 v: |/ s
Set fc = f.Files
+ I6 r& e6 R8 g  `1 K) _For Each f1 in fc
0 U3 d7 m. v  r2 Z9 ]8 [4 Zs = s & f1.name ; F3 X4 t' z6 g' Z2 t
s = s & "|" ) C: n1 c* r$ f
Next
! d) p3 `; ?9 G; n1 ^ShowFileList = s ( F; f5 q3 G/ J- r+ V
Else
1 s' O* O) ?- G  h! iShowFileList = -1 ; a& E: `" N+ S
End if
' Q$ u$ a; X7 a  x/ [& C* ]: `End Function " A1 U& O! |9 [+ P2 a' V2 S

0 }+ I0 I2 d0 A& J'文件复制
$ N7 M' o% v* o1 HPublic Function CopyAFile(SourceFile, DestinationFile) 7 \; ^% a0 O+ A
Dim MyFile 0 |- w+ ]; q2 |6 s) `/ r
If ReportFileStatus(SourceFile) = 1 Then # N) X6 a$ u# ]6 G
Set MyFile = objFSO.GetFile(SourceFile)
% v+ Z3 \; [1 O' t4 D7 Y% S% XMyFile.Copy (DestinationFile)
3 t, M2 y5 x9 R( pCopyAFile = 1
! P8 p  x4 z$ @2 `1 SElse 1 j$ ~" b% n9 V: e# T2 M
CopyAFile = -1
( ]8 ?! X% P3 u8 n7 s. J: k6 EEnd if , P5 c$ ?5 e0 g( x& ]
End Function
: _# S8 @6 K6 E! o6 w) M  _, j* E, \" t5 `# f' m
'文件移动 $ s' `& S$ D2 `4 |
Public Function MoveAFile(SourceFile,DestinationFile) ' o$ h2 Z7 _+ `$ e( R5 G) T
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
" K  }+ L3 [: b! L4 p7 BobjFSO.MoveFile SourceFile,DestinationFileORPath : W7 l# a" d% |0 ]8 B+ Q, h: b7 s. t
MoveAFile = 1 / h! [( [: y6 _5 |
Else 8 d* J/ n( j' s; a
MoveAFile = -1
4 o: A* j" Y( j5 w. o  {End if
/ n0 U% ^" b8 w3 U0 X5 REnd Function
& j% J( ^0 {& Y1 u! q2 [
: E5 p' H( R$ _& l+ U! R'文件是否存在? : r3 ~' R0 [5 P3 M+ V
Public Function ReportFileStatus(FileName) & f6 m2 S- W) D3 D2 d- H  W3 w0 r6 L
Dim msg
8 x2 e2 u2 w( E0 r$ ~4 Gmsg = -1
0 _0 f$ A, K' t+ m9 ?4 x3 m: DIf (objFSO.FileExists(FileName)) Then
0 u& T9 O$ n* g4 _4 }$ Nmsg = 1
" |5 {  b9 f, P$ {8 \7 bElse
+ U2 w) r- h9 v' P! \msg = -1 2 t& S) x9 {6 x3 q+ m8 x3 g
End If
! n1 T. _3 O7 L0 ?ReportFileStatus = msg
1 F8 C5 i, g0 |. J' B. vEnd Function
: ~" D# m4 Z9 Q( q" v
+ O: m6 I, X; G" G. c'文件创建日期 # `; m; D) q# r8 k; ^
Public Function ShowDatecreated(FileSpec) 6 l) s4 X+ N, i
Dim f   s* m% w6 @6 d6 c( \
If ReportFileStatus(FileSpec) = 1 Then
. ~9 O2 [5 u1 j7 U& [Set f = objFSO.GetFile(FileSpec)
& v: P) e# d" S: f6 Z0 UShowDatecreated = f.Datecreated
& t& E% G2 [5 ~2 h8 pElse . }" E4 }3 {+ A/ j# q/ J  J
ShowDatecreated = -1
+ k0 o+ `0 _* a( C' JEnd if / r5 X% W3 W+ ]9 h2 E
End Function
7 h$ ?( K3 h1 B  f- p
+ d" l5 I: P: P$ g& y& S- T'文件属性 0 k. z. h: ~. [' e: Q- l$ {$ P
Public Function GetAttributes(FileName)
: o1 l0 R& W0 [  r9 jDim f
- q$ s/ ^# Q. ~0 w, d/ }6 X; kDim strFileAttributes
" Z4 [. D0 a, o2 C9 E& ]If ReportFileStatus(FileName) = 1 Then , q/ E/ u; m4 H8 M- @
Set f = objFSO.GetFile(FileName) 9 L' h& z" Z4 z
select Case f.attributes 8 x! v+ p- i! L: L) @
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " 2 s! w1 a- M" {: E+ |/ U
Case 1 strFileAttributes = "只读文件。可读写。 " , t# I$ [/ \5 e" ^
Case 2 strFileAttributes = "隐藏文件。可读写。 " 8 W! D! ^! \% M
Case 4 strFileAttributes = "系统文件。可读写。 " 6 w: W  G5 G5 x5 E) e9 \
Case 16 strFileAttributes = "文件夹或目录。只读。 "
$ R6 O8 z4 l+ B4 l1 ^4 P0 qCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " # X) I1 K* v  p4 L* u! C4 L" m
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
: k; s7 o0 ~4 g6 {4 t; y6 n6 UCase 2048 strFileAttributes = " 压缩文件。只读。"
8 l: m6 @' y. w! i, K9 |End select 1 Y6 k) m4 M% r2 k
GetAttributes = strFileAttributes
& ^2 `. j  z- ?( p5 @/ @Else
/ v$ Q! i; l) e+ V8 L( ^7 F8 XGetAttributes = -1
0 [! {1 M2 l) E* `( GEnd if " |7 G6 w2 X$ E! \- W  P# |) _0 y
End Function
4 @! \& k+ g/ p; Z* U1 p+ V
; f9 Z4 A* n5 K% Q/ K. b'最后一次访问/最后一次修改时间
/ V: z+ K: T! U' k! p1 pPublic Function ShowFileAccessInfo(FileName,InfoType)
% d1 `' L0 [4 S) J* G- }'//功能:显示文件创建时信息
  @  {% N) k0 k7 z# o2 b'//形参:文件名,信息类别
0 b. ^9 o  R0 j4 B6 S'// 1 -----创建时间 1 ^2 D6 M. @/ v9 o! P: x4 l3 n" u
'// 2 -----上次访问时间
7 B: L1 P( D0 X% ^0 |'// 3 -----上次修改时间 " o) e3 `( x. T) W
'// 4 -----文件路径 + ]+ m9 ]0 X: W
'// 5 -----文件名称 9 Z/ z% e, P- I) k4 l; j
'// 6 -----文件类型 ( e7 N! g$ z4 S" o: x! x- q
'// 7 -----文件大小
# f; a) x, W7 u$ |. y'// 8 -----父目录 9 v" b2 x9 W5 X: [6 d7 x
'// 9 -----根目录 - z  x2 V, o. x, \& |& m
Dim f, s ' j: V2 r% O3 q
If ReportFileStatus(FileName) = 1 then , g8 S  Y+ H- V5 f- A7 {
Set f = objFSO.GetFile(FileName) . q. f4 \& o6 t
select Case InfoType + N3 U- ]7 _2 u( [( ]6 h4 b4 v
Case 1 s = f.Datecreated / B9 n5 s$ S1 O" f4 P, |7 e+ v
Case 2 s = f.DateLastAccessed
2 U- W! `6 X) ?) k- cCase 3 s = f.DateLastModified
0 ^- V- g" d( VCase 4 s = f.Path ' U( A7 U; C' W* p/ Q4 j. \* ~4 c
Case 5 s = f.Name
9 |4 Y, U9 S  p: g# ~. h. Y" |: \Case 6 s = f.Type
  e0 w- K: Z& R1 Y  M/ @Case 7 s = f.Size 3 O7 r1 Q: i! b. R0 K
Case 8 s = f.ParentFolder
  X% }" U" L1 A6 S, c" PCase 9 s = f.RootFolder ! A& f( s' \7 K
End select 7 b+ j7 s, L, i( p7 O
ShowFileAccessInfo = s
$ z, |9 E8 e, ]7 p* FELse ; E& ]; J" e5 D# a  h
ShowFileAccessInfo = -1 / J& ]# P3 O$ \6 ~. I2 N2 G1 \
End if 4 q# Z0 i" y/ [  l' d' C* K
End Function
1 \) ]: X9 ?( e- D+ X0 @* n* c
- ^! S  q* a( \1 D8 q+ \; \; r'写文本文件 8 o# S$ \3 x+ j. C5 L4 Y
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
  b# Y2 y. }/ p) m. _+ P, R: v2 ~Const ForReading = 1, ForWriting = 2 , ForAppending = 8
; ]5 {! g  O) }  D9 `. RDim f, m
5 n1 @" Y4 @+ H" `select Case WriteORAppendType
" C2 Q# K* `) j& q8 h5 i1 P+ }Case 1: '文件进行写操作 9 b6 ^  u$ ~! H2 h: I5 C: ^' o: Q8 \
Set f = objFSO.OpenTextFile(FileName, ForWriting, True) , {7 R, Y! Q4 Q0 r1 ~1 y4 ~: J+ f
f.Write TextStr ! i2 J* a3 I# ^7 \
f.Close 7 E) u, F1 N1 g/ F6 B8 o" t0 q
If ReportFileStatus(FileName) = 1 then , K6 h" F% @+ o' O9 _) v( z8 l
WriteTxtFile = 1 & K( J# d/ e6 ~  v$ d' S* H
Else
& \! Q# |" }0 @WriteTxtFile = -1
& G% U$ k. K8 [3 _+ a' ~End if
9 w* m( _$ U# t" O& DCase 2: '文件末尾进行写操作 / d8 M9 o8 U' C. J: B, R$ p6 c
If ReportFileStatus(FileName) = 1 then % k1 Y! x8 \+ g6 A, F) m+ B
Set f = objFSO.OpenTextFile(FileName, ForAppending)
. i  t; k, m; T3 {- ef.Write TextStr
. m2 z, B6 i' b+ ^f.Close
. z2 x* ~- j( [1 rWriteTxtFile = 1 % a4 Q, }8 ~( w7 c3 j: s+ g- r
Else
8 V0 l& F) _( TWriteTxtFile = -1
* E* k/ c" @" g5 EEnd if
; K+ U7 D  s- s7 b, Z3 s6 xEnd select
# j6 v' ^& d5 T$ i  SEnd Function
4 H  n- `5 k4 j
  @4 f3 ]" n& ^( O$ Q: k+ Y7 O2 T'读文本文件
9 f0 y9 S6 b+ c# U0 i2 `6 \Public Function ReadTxtFile(FileName)
  A# F( `. K4 d0 V4 e% ?9 X! Z: qConst ForReading = 1, ForWriting = 2 ) g, S6 N4 ~1 s* n; B1 q* k2 r3 D# C
Dim f, m
2 @  h- A1 W: D7 C$ j: A- G! TIf ReportFileStatus(FileName) = 1 then
0 a% U8 k4 k: e, y  C1 BSet f = objFSO.OpenTextFile(FileName, ForReading) $ b4 M$ H, C; K. k, C/ x
m = f.ReadLine
6 Z" b6 _0 F. U& ^$ n' ^( GReadTxtFile = m 5 Q- T5 b/ U! I4 A9 v; {
f.Close * @- R, a- \1 t" M& D( D* H
Else
2 |2 @7 k0 M" F+ N7 hReadTxtFile = -1
3 {# I; {: J$ m4 [End if . [0 D  l0 T* P( S
End Function ) e5 T5 u- B$ e
- e8 M4 Q" R/ R  P$ A
'建立文本文件 # X. r2 t( ^3 P* W' `, h% [
# ~1 T+ d( a- ?6 e$ k! N5 X
'=======目录操作========
' M) @& [2 U  |; p: V3 K, O) H. p'取目录大小 5 m; i& J( ?5 _0 R' }/ J' y9 m3 e
Public Function GetFolderSize(FolderName) ( W9 Y% T. a$ g) ]2 F6 a! b
Dim f
8 y7 |" e  P" }1 M  j3 u* FIf ReportFolderStatus(FolderName) = 1 Then # C4 E% a" p: l6 T0 H
Set f = objFSO.GetFolder(FolderName)
3 o6 g7 D9 ~7 g( ]GetFolderSize = f.Size
( }- Q, C: B0 e" A: C' \1 q3 N! {, tElse * l* ~) F1 r: g, V9 n& W' `
GetFolderSize = -1
7 A9 x/ c3 h8 t3 E7 M2 m, QEnd if , u. u6 B8 X! U5 S/ P9 v, f$ N
End Function 9 H6 o. t8 V9 {) T) u' _

/ f3 W5 c) f- C# s1 I( X'创建的文件夹 / J+ d, @9 O6 V
Public Function createFolderDemo(FolderName)
8 _( }' I7 U% i  \' }Dim f
: r! I8 p4 b0 Q9 y0 j. D7 r5 o' dIf ReportFolderStatus(Folderspec) = 1 Then
' w+ k0 c: o4 O# s5 g% {createFolderDemo = -1 2 }+ o  U5 O( ^% I
Else ! s4 t- s+ ^( {# W  X0 }/ Q
Set f = objFSO.createFolder(FolderName) 6 V; Z5 Z6 |, L; I3 l
createFolderDemo = 1 ! A0 l& t7 k. d
End if
; E; y9 J. g, Y, cEnd Function & H" o$ f, h- D0 B5 O

* l6 _# B7 w- {$ [7 ~9 p1 G9 n* v'目录删除 : t; u/ s" {1 W" ~
Public Function deleteAFolder(Folderspec)
; o  S' L7 P8 W" e' I0 LResponse.write Folderspec / r: i: d/ Z! T3 X' u/ Z- g
If ReportFolderStatus(Folderspec) = 1 Then 6 f7 e& A# a) _+ @
objFSO.deleteFolder (Folderspec)
" J. p. z% s- N) \0 |deleteAFolder = 1
/ ~) V4 a  n0 ]; \+ z& @; [$ HElse ! S; h/ T2 x2 V
deleteAFolder = -1 % `3 X* W- F3 J; ?2 G' |5 ?) S4 K/ D
End if
4 i) u6 x7 U/ @" }9 G$ YEnd Function ( D, O' V. g  F/ Y
' Y1 i$ y% E# [
'显示目录列表 # W, p* \$ c9 r5 d# a5 T: Y3 f
Public Function ShowFolderList(FolderSpec)
: }1 T! b) O( V7 U3 CDim f, f1, fc, s
1 X- e4 @. M2 w7 C" L; bIf ReportFolderStatus(FolderSpec) = 1 Then . \5 D3 y0 u" W# h
Set f = objFSO.GetFolder(FolderSpec) ) a: E/ ?5 }/ k! |9 |5 ~" V
Set fc = f.SubFolders ( N  [% [$ v6 n9 s
For Each f1 in fc 8 r; q' r4 S0 M' ^. f& y* O
s = s & f1.name
! i* r2 L; F( Q  l+ T; Ss = s & "|"
: ]3 W" F2 s) a$ uNext
/ X& G0 L5 N1 r( W7 zShowFolderList = s
& s2 A4 M3 z6 J+ v/ |Else / h/ b. z+ e* x# {
ShowFolderList = -1
* E5 z# @5 V$ Y8 cEnd if
  ]4 i: }* E* B( c- REnd Function   P/ S1 l4 p2 \
2 t& T) h5 Z% b/ M! e1 E
'目录复制 / b2 @5 k: I% s- s+ C
Public Function CopyAFolder(SourceFolder,DestinationFolder)
# a% j: B% l/ Q0 B, WobjFSO.CopyFolder SourceFolder,DestinationFolder & y4 S+ n' f8 Y, F
CopyAFolder = 1 ' C3 f+ X7 O: U' ^8 ]6 R$ |( B
CopyAFolder = -1 " A( n& K& v; w7 P
End Function 4 F7 M' r6 {& p

0 j8 |# k" N- o# |$ n' Q  l; z, w+ r  G! K! D5 x3 F. h1 h
'目录进行移动
. e( ]3 C7 Z& j7 f, OPublic Function MoveAFolder(SourcePath,DestinationPath) - W( ?  R; I. z4 c( Y$ F: J& k
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
2 j. v8 t: V3 N5 KobjFSO.MoveFolder SourcePath, DestinationPath
( d5 }* p# ^2 f2 Y# GMoveAFolder = 1 * |. q4 b& A7 Q& N  }
Else
( l; \, m5 m$ P4 P/ Q1 jMoveAFolder = -1 , A) V. V+ G% u9 R. I
End if ! Z( y% p- A" L. j9 h
End Function - _& G9 E* v; ^6 C* U( N4 _

6 C( r) D8 i2 F* o2 R2 b7 a'判断目录是否存在
1 t+ p( O. H4 j  G& `Public Function ReportFolderStatus(fldr)
6 ?1 f& k( y# O# R: QDim msg
' w/ w+ M9 i3 ~/ o; j  a8 O% Dmsg = -1 3 y5 i5 ?' c- U3 `% k- U% v* Y
If (objFSO.FolderExists(fldr)) Then
( I1 p8 C, v% Z; K& Tmsg = 1
: N3 i6 p, m7 f1 n  N" qElse
' _7 P( v" e+ D/ G. Jmsg = -1
, Z  o1 A( b& W6 H* tEnd If
0 Y. c- w0 Z/ n8 v# i: xReportFolderStatus = msg
/ D# v8 {& V1 u8 w- n6 c4 m; WEnd Function
- `* G4 i- f! ?6 v7 |" ?( E2 H5 r; t& l) F- ~
'目录创建时信息
% v3 b4 }1 Q6 A9 cPublic Function ShowFolderAccessInfo(FolderName,InfoType) 3 i. b% J7 B" A8 F& j! P' k5 C" @& T
'//功能:显示目录创建时信息 8 L1 ?4 b. ]2 m* h% X7 c
'//形参:目录名,信息类别
3 d: O6 K8 G1 Z1 F6 r- y'// 1 -----创建时间
# O3 B, h) T3 @'// 2 -----上次访问时间
5 U5 b% z, Y2 e2 F2 ^'// 3 -----上次修改时间 " O6 a- z3 e, n  E$ a
'// 4 -----目录路径 % e8 d9 q, H/ ~+ R; ~$ y3 V4 @# T
'// 5 -----目录名称 3 r* B" w9 Z+ P6 [* L
'// 6 -----目录类型
- Q: b, O" [7 e$ g, k'// 7 -----目录大小
- y* n7 H: C& B) _'// 8 -----父目录 ; `- K; @, Z! u, h; E
'// 9 -----根目录 ) e8 O7 e$ j) a" f* l: ^/ B
Dim f, s " G1 T2 q& w/ v1 e0 ~1 [8 L3 a
If ReportFolderStatus(FolderName) = 1 then , |- R) m- i5 S9 B, Z1 I. |, a
Set f = objFSO.GetFolder(FolderName) ; X6 T# G9 C% y1 r: g
select Case InfoType ) H) w  ~0 \! f6 @6 K/ A! ^* Q
Case 1 s = f.Datecreated
+ P1 t5 z+ F6 c# D  Q: ~Case 2 s = f.DateLastAccessed   e2 r7 w$ p+ B) K4 s- @
Case 3 s = f.DateLastModified
3 j8 h; c5 P" y- ^9 @7 a$ _  w1 V* O9 JCase 4 s = f.Path ' l) n2 _* |: d: \4 c" z5 U
Case 5 s = f.Name
0 h, q+ N/ b  U# r1 _9 T. VCase 6 s = f.Type
  B" u1 f5 M- l7 RCase 7 s = f.Size ; u" c" `! N& [+ w. ?
Case 8 s = f.ParentFolder
6 \! y* k3 P7 DCase 9 s = f.RootFolder ' c* C4 J0 q! z0 @$ ^
End select
* X, x1 L9 d: ~6 N& {ShowFolderAccessInfo = s " E+ a9 T! ^' ~5 V+ R
ELse
7 ?5 c  [# d4 i* o& c, PShowFolderAccessInfo = -1 + `( h+ E; r% h
End if
& ?8 A3 M" B0 {0 \End Function 6 e) H1 d& S' L5 n/ D; l0 L

9 d1 S* Z& C9 }8 ]+ W+ k'遍历目录 , w& l0 C9 {8 \* W9 q
Public Function DisplayLevelDepth(pathspec) 3 Q! V+ R0 b+ b+ ]' i* ]- t
Dim f, n ,Path 3 t0 R; P3 {# g* a$ W* I
Set f = objFSO.GetFolder(pathspec) 1 ]# ^! n6 }, W  g6 x( l- d
If f.IsRootFolder Then 8 ?9 K- m/ J, p( m* H4 C9 r
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder - y: J( C7 A8 Z* k' ^4 f
Else
- d# v* ^- W) D" i0 ~0 p5 {, JDo Until f.IsRootFolder
) v2 L- O3 i' Y9 I/ DPath = Path & f.Name &"<br>" 8 c" ?+ {3 [2 i- V, q1 q! i! J
Set f = f.ParentFolder
2 z+ Y- O5 j( g1 zn = n + 1 / ]# ~/ i* K/ t; [1 h
Loop 5 T) ^) f, @; i; l' Z
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
" B# M! b- `$ y. G; q& i) p/ h; |End If
7 m( W+ R. w2 k* b) j8 K: A# F  x. ~End Function " u5 g5 J/ K8 o! \( E
+ F  S5 d4 m  w+ X9 p
'========磁盘操作========
  k( J7 D+ ]+ k5 r7 X* E2 E'驱动器是否存在? 2 Y5 U( {- z$ x4 U
Public Function ReportDriveStatus(drv) ; \8 K6 \& Q7 ?8 v' T6 b3 c! I. L
Dim msg
! S4 W3 z& k' Z/ ^0 j( Umsg = -1 ! f) k* v4 L) h4 C
If objFSO.DriveExists(drv) Then 9 K; T1 v( n3 J( G. Y8 _
msg = 1
. v* q# W( Y% n( `Else
- C( G0 h9 g) r0 W7 smsg = -1
" m1 G# I5 @' _. yEnd If
5 x5 P; d; `" V  J/ ~* m$ gReportDriveStatus = msg
+ M& U6 U$ u. O9 BEnd Function
4 e# P' M# Q, h- \
; b" h& t# |# \4 i1 a5 b'可用的返回类型包括 FAT、NTFS 和 CDFS。
) p' D. w% Q/ \2 D( _  qPublic Function ShowFileSystemType(drvspec) 3 Q4 R$ P+ w7 G/ h# ]8 S3 F" W, x
Dim d 7 Y) M' t# c' D2 D/ C
If ReportDriveStatus(drvspec) = 1 Then
* f7 t' `2 j# @Set d = objFSO.GetDrive(drvspec) 4 u+ Y; |/ ~$ K& q1 I  E
ShowFileSystemType = d.FileSystem # }0 E. s  d  U! y( S* x
ELse
+ c8 P" M  m( ?4 h  [% QShowFileSystemType = -1
$ L" G( Q/ T1 u  @: wEnd if
' X! I$ [! m; m" V; A+ HEnd Function 5 V" k; {1 y, v: ]* F* f
End Class
" ~. y; e' i5 A%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

GMT+8, 2026-9-21 22:40 , Processed in 0.029405 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部