【高州情】高州人深圳站

 找回密码
 立即加入
查看: 641|回复: 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文件操作大全( B4 P% n- q; S+ T- f, K) X
<% 2 s: l1 ~, b4 F
Class Cls_FSO
7 p5 [$ h/ \; c8 p5 e- ePublic objFSO
0 W* P' o* q* s7 x+ HPrivate Sub Class_Initialize()
  Y' F+ {9 b. q7 c2 x3 u* |Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
; L4 Z1 J$ F' y0 Z( Z% R* |  [End Sub : D$ O. L7 O( O2 J: Z+ c: W" s
Private Sub class_terminate()
% u" z# B) [+ H7 N; i. N2 t) }; nSet objFSO = Nothing & _: V7 L6 a5 }: c( F* C& ~" i
End Sub
. Y+ N. ]8 R0 o* B/ [& e  I0 l
+ r2 G* M( N* U0 G'=======文件操作========
" u: o+ A7 L0 Y! H0 a- v'取文件大小 ' K+ F+ V1 Q( B  r" S, d( |- U
Public Function GetFileSize(FileName)
6 n, ]8 u! a! }; dDim f
) @$ E3 z) Q# ]9 C; b( lIf ReportFileStatus(FileName) = 1 Then
" X9 C+ }0 @# O9 p$ x& W4 K) F( j, QSet f = objFSO.Getfile(FileName) # r" I% M  h; x, L# b. v
GetFileSize = f.Size 9 c3 A, q, t0 j0 l  K6 h
Else
+ W5 Z# c2 }# e* c9 P) j. sGetFileSize = -1 $ {( K, d- Y5 S  }1 E6 l* ?( I: ~# ]+ _
End if 2 e4 w/ o! f2 ^( L5 F7 C
End Function ( i& s) z! d  _1 t
+ H3 Y3 _% P" \) z& d4 o0 d
'文件删除 7 k( T' k( ~8 ~) O: M5 u
Public Function deleteAFile(FileSpec)
+ ?- a0 Y- p2 l* Z9 A0 E& aIf ReportFileStatus(FileSpec) = 1 Then
5 }6 n+ m7 ]5 zobjFSO.deleteFile(FileSpec) & _# o6 J, \% Z  k- l3 |( C
deleteAFile = 1
/ s# Z8 C0 T# V/ xElse ; U" T" N9 a! }( ?/ J1 {
deleteAFile = -1
6 z' a0 J+ ]2 }0 [2 b! REnd if
. c8 }- {: V# G) IEnd Function , H6 S" i4 m, A& p, n6 B6 Z1 |4 ]
# I3 M$ r, K3 T1 |" \: b
'显示文件列表 * Q2 s0 C5 `+ M
Public Function ShowFileList(FolderSpec) 4 F' g+ u9 R4 \( ^' T# y
Dim f, f1, fc, s ) p& @  A" z( @  P9 ~
If ReportFolderStatus(FolderSpec) = 1 Then
( O; j. r7 J; s) N/ [0 e1 ySet f = objFSO.GetFolder(FolderSpec) % C4 w0 j5 n5 B) U7 N7 F- C
Set fc = f.Files 6 Y' L" s. i7 }/ b+ c
For Each f1 in fc
( \$ X# L2 W) l5 u. Ks = s & f1.name
/ v5 D3 T4 ^5 g6 R: }' Ts = s & "|"
5 {- a: O( R- a: j! aNext . l$ ]1 e# h5 l9 j; S- ~5 W6 ]
ShowFileList = s   F3 f6 A* ~- m# @; u/ J/ I
Else
6 C! e3 I; N6 {$ NShowFileList = -1
2 b4 a/ R. u( j0 E  {End if
( T: b$ x1 w+ dEnd Function # A: f- Y' `2 L4 o( m
" D, j7 ]3 c' p0 }* I+ C
'文件复制 - x8 Q9 I$ c5 f+ [- u; r' Z) P4 t8 g" `
Public Function CopyAFile(SourceFile, DestinationFile)
7 u7 [5 r/ W* ?Dim MyFile
0 f( T7 O6 K9 E6 ~8 WIf ReportFileStatus(SourceFile) = 1 Then
% y. \% X- H4 f! d6 TSet MyFile = objFSO.GetFile(SourceFile)
9 ]1 @8 v& v6 P. y, \# f& s4 w; PMyFile.Copy (DestinationFile)
9 F: u! F$ i- T, tCopyAFile = 1
* B. Y  \$ k* d1 e0 B% s# bElse - N/ c' M, l% M  D- _, h
CopyAFile = -1
1 j' Q; ~' A; G$ z: i! l, N% WEnd if
8 Q% e- L* G! @! j4 J3 D. VEnd Function
( W5 D2 l4 _: I1 h; V- ~# t0 y: M7 U- e. b) i2 ?3 C
'文件移动 / k  d% m8 _+ I5 S( P! C
Public Function MoveAFile(SourceFile,DestinationFile) : s0 {3 {8 x9 e1 P; v- X$ U# i  p
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
$ V  j! C5 v+ y$ f+ I% b. v+ {# zobjFSO.MoveFile SourceFile,DestinationFileORPath
) Z/ L8 p4 {% ~5 L; Y& {  L8 L7 qMoveAFile = 1 & f9 y3 I1 M7 g. N
Else
" ~# f8 \) A/ r5 I  H0 R) kMoveAFile = -1
/ b' m! h8 _* i5 |End if
- e8 d& ~0 h' D* CEnd Function   i& Z( t. C; F* ^( H& T
2 ~8 a, w/ T! G" A0 w2 D6 T
'文件是否存在?
  I0 M$ B+ t" V+ mPublic Function ReportFileStatus(FileName)
3 f3 B. v7 a- \1 c$ `Dim msg
* N. U9 n! d" u; w- s' f9 n( I( |( lmsg = -1 , |; \8 Y& r# _; z: j7 P# t+ l0 P9 `: u
If (objFSO.FileExists(FileName)) Then
8 C6 x8 M6 s" K6 i7 j7 Z- }: Tmsg = 1
. Y: w. P( Y9 k6 L" jElse
1 v4 Y5 w9 P. ymsg = -1
0 _/ X4 p6 \9 R/ j5 sEnd If ( {% C' `$ P& b/ p) f
ReportFileStatus = msg 4 F  @5 @0 N" q' x' M
End Function   U, _- N5 w5 X; `  I6 G
1 e7 s# _% R6 l) O
'文件创建日期
2 Z2 S8 o  i' B3 h! @3 sPublic Function ShowDatecreated(FileSpec) + S! B5 H2 C( |2 E0 E" ?+ b/ x. K
Dim f
7 g: [, ^5 W' MIf ReportFileStatus(FileSpec) = 1 Then
; `1 A% |# b3 S5 S+ ?, DSet f = objFSO.GetFile(FileSpec) 7 D2 L9 d8 ]2 `6 {) ^( r( P
ShowDatecreated = f.Datecreated : i; R; ]+ C/ F! I9 U
Else ( o8 [3 f& s6 W" s+ _
ShowDatecreated = -1 5 `' H& J5 p8 A
End if ! G$ w+ e; c) N+ Y
End Function : k0 j4 }7 o6 q+ I5 \* f, s

$ ^# G$ h# V; m% z- z; d'文件属性
+ D1 k* ~' Z! R+ L6 c0 _Public Function GetAttributes(FileName)
) R% P0 t" ~4 l# q2 T3 _& ~Dim f 1 ^9 H, K; ]; Y8 Z9 e, s( y
Dim strFileAttributes 2 p5 ~' U- _; k4 F! P% t, _
If ReportFileStatus(FileName) = 1 Then & X) ]7 k  y4 D- _) C  [- K
Set f = objFSO.GetFile(FileName) 2 w/ M9 I& C  ?
select Case f.attributes 5 Z- a" B; @/ }2 q
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
1 g% o! a9 ~4 lCase 1 strFileAttributes = "只读文件。可读写。 " - o7 W" y3 ?% \, W
Case 2 strFileAttributes = "隐藏文件。可读写。 "
( W3 V9 t8 E, Y$ T, p2 g2 M7 zCase 4 strFileAttributes = "系统文件。可读写。 "   g* A' Y3 B; C' H
Case 16 strFileAttributes = "文件夹或目录。只读。 " ) g. r4 }) u! q
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "   k4 e  @  w* A! o+ Q6 {7 B
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
$ H1 E0 U/ i/ m2 kCase 2048 strFileAttributes = " 压缩文件。只读。"
+ E/ S7 L8 W1 iEnd select ! S- A6 I3 w# ^8 s2 C
GetAttributes = strFileAttributes
6 t4 F7 O, L9 _- R: @% rElse
) w3 Y' c) e& g+ x- a4 rGetAttributes = -1 . k) {# h* V9 z) J
End if
" e% |7 P& t+ \5 k) }  ~. OEnd Function
2 q, S( G* I) }" x  O
7 q- l; p6 O7 T& Z% \& G1 `'最后一次访问/最后一次修改时间
, s& @) D& A, i, HPublic Function ShowFileAccessInfo(FileName,InfoType)
' D6 A: d+ D& T9 @'//功能:显示文件创建时信息
; C1 Q2 Q2 d$ w; _'//形参:文件名,信息类别
: i  S9 l( ]. g'// 1 -----创建时间
" }/ R5 u: A# r# h  a'// 2 -----上次访问时间 0 X5 s; g  y1 @! t& i* R
'// 3 -----上次修改时间
( d2 M! g) Z5 W/ i( c9 ^0 z'// 4 -----文件路径 # T7 G$ M$ c" H
'// 5 -----文件名称 ) m5 W: O$ E  e$ j! c
'// 6 -----文件类型 7 {2 \) {0 `. c5 H
'// 7 -----文件大小
! J+ P# z1 J2 Z0 C+ n* ~  {3 Y( r'// 8 -----父目录
# I! ]# d. N$ [7 l. C4 V'// 9 -----根目录
+ Q; j1 k- b3 l5 l  o! |Dim f, s 6 c: ?: c& |& o1 W
If ReportFileStatus(FileName) = 1 then
5 U2 w$ ?7 }' K# QSet f = objFSO.GetFile(FileName) : A' b$ W' E5 L( O$ u
select Case InfoType + ~7 t, h; o. Y; I) L
Case 1 s = f.Datecreated
. ]5 M0 K4 u, iCase 2 s = f.DateLastAccessed 3 m4 g5 L7 e' @6 Z- p3 h
Case 3 s = f.DateLastModified   \0 H/ d9 O# v8 ]3 Y5 e
Case 4 s = f.Path
9 I9 D7 _  O$ P: LCase 5 s = f.Name
/ J, y% x& n# W2 N7 cCase 6 s = f.Type $ c9 ^0 E% j; t
Case 7 s = f.Size " R% V5 b+ b2 D# V
Case 8 s = f.ParentFolder
1 U4 Q: w8 E6 L. r& dCase 9 s = f.RootFolder 5 U* K; l* _$ n/ U8 g
End select
; x4 l$ Y7 Q$ D8 u. vShowFileAccessInfo = s
4 s  A( N5 y- @! ?! j8 m# QELse
" d4 \3 n8 `) |5 U* HShowFileAccessInfo = -1 7 X3 D2 q& R1 z- x2 n$ A# z; e, Z  b
End if ( R# \$ f. k% ]0 H
End Function & \9 |/ @4 y# W# [! c8 u
/ K$ S/ L$ x- ]5 \
'写文本文件
' V6 S  {) s" G4 N- _# WPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType) & }0 V0 x! W1 L9 O* Y
Const ForReading = 1, ForWriting = 2 , ForAppending = 8 2 {* R- z& }3 B4 i; K
Dim f, m 6 n) `6 W; N! ]6 e+ @& W
select Case WriteORAppendType ) c! g5 P9 K% P
Case 1: '文件进行写操作 ' k: j* N  Y- N0 S
Set f = objFSO.OpenTextFile(FileName, ForWriting, True) + s; M$ c3 T' O6 s+ ?3 q
f.Write TextStr ) P: X* @3 I6 r( Q. v( m
f.Close 2 k6 I$ g1 z& t1 z
If ReportFileStatus(FileName) = 1 then ( m( B$ d2 E  Y7 ?+ k" ?) b* u" N
WriteTxtFile = 1
! }2 Y5 K) t+ l& P, {+ UElse # V) |- s6 M5 \1 Q1 f
WriteTxtFile = -1
. |( o# w5 B5 N+ W: N$ b/ \End if
) @: {. u9 @! `. \" k. dCase 2: '文件末尾进行写操作
& K% M& c8 j5 [$ Q" x" SIf ReportFileStatus(FileName) = 1 then 1 q4 i/ U9 p( ]
Set f = objFSO.OpenTextFile(FileName, ForAppending) 4 g. R) m4 R7 @
f.Write TextStr
% K. F9 ?6 H9 v% Y2 If.Close
8 Z( c# x$ D5 l0 m% A$ ?WriteTxtFile = 1 1 t! O: H  Z$ S8 T- j" z) r
Else
$ s0 y3 I4 G7 U% oWriteTxtFile = -1
3 h# V  V1 E8 @, E9 i7 w3 z, aEnd if ! T3 j/ C" S) x8 {- s
End select + [" e: {9 q% `! G9 w( Q
End Function 0 |0 H; a3 z' F
4 Z! z$ D" p8 ^8 ^& A% L( I
'读文本文件
8 r# E/ n5 T' d3 YPublic Function ReadTxtFile(FileName)
9 d5 d5 U. t5 ]. AConst ForReading = 1, ForWriting = 2 ( g" A) n" j" H
Dim f, m
4 V' Y) B* H9 U7 j+ ~If ReportFileStatus(FileName) = 1 then
8 i( U3 ?+ U/ r$ }8 }; ESet f = objFSO.OpenTextFile(FileName, ForReading)
- P, Q/ C$ t/ A$ km = f.ReadLine - q# K$ s) T) D+ u0 W* A  D  ?
ReadTxtFile = m - f/ Z2 H; _9 e  u- S
f.Close
6 \  r% Z/ A* f- ^( UElse : D5 a, V5 e$ U: a
ReadTxtFile = -1
. M7 h: q* r1 Y( K, XEnd if & x8 y2 |, Y/ R9 d4 o
End Function
- K* B- F  X6 d3 c8 ]: @3 [2 Y4 k: c( I! U% c
'建立文本文件 1 D& t& p9 |5 Z6 B; a

* `1 d/ V1 J3 j( G% B2 e'=======目录操作========   j. X+ e4 C% g! ~1 c0 W: V5 u
'取目录大小
/ g2 K9 k1 f* K; Q' O, e) X( ~Public Function GetFolderSize(FolderName)
4 m- N) m& i9 o7 O/ c( QDim f % h- ~; f4 {2 m7 K4 N
If ReportFolderStatus(FolderName) = 1 Then
9 D7 U. X! W7 U; X- J! I: hSet f = objFSO.GetFolder(FolderName)
8 O  s$ N6 u. @$ v* s6 h  K/ I6 dGetFolderSize = f.Size / _" \) S. t$ h6 T& _- j( N' f
Else 6 ]  S8 l' h) e+ R; c1 E  l
GetFolderSize = -1
$ L4 l$ N- h/ m. p" K# }' k$ u$ ]End if
. `# M) n8 f- ^6 O- d8 hEnd Function
/ c! O/ H( C& d. Q2 Q6 M$ T- v
" H3 |/ r% B/ q1 l6 W'创建的文件夹 ; ~! p) B8 s" |
Public Function createFolderDemo(FolderName)
' X2 i5 u- K+ W+ IDim f & a  D1 g$ n' U2 b* @5 R8 j% F
If ReportFolderStatus(Folderspec) = 1 Then
9 h4 E, }. [- R4 y. Q, LcreateFolderDemo = -1 , R. s8 b0 _! z
Else 3 S9 b" Z4 n$ G
Set f = objFSO.createFolder(FolderName) 8 v2 `* e( k: B3 B& D+ C6 {* T
createFolderDemo = 1
( F' Y8 _1 s! Q( |. Q7 ?" DEnd if ; y; E# B) \6 q% h
End Function & r* c1 k+ H5 b& k) ~$ d6 g, m5 |* `

; z$ ~7 ^* P0 K& w# f1 `'目录删除 ) H1 D1 ~+ B' {( \2 ^
Public Function deleteAFolder(Folderspec)
" y0 N- |3 }5 @1 N* N+ MResponse.write Folderspec 1 p% b2 h& U) t- t; i5 s' g
If ReportFolderStatus(Folderspec) = 1 Then
$ a2 {3 k0 Z3 l% LobjFSO.deleteFolder (Folderspec) 1 F! j4 ^& C0 j. F- k
deleteAFolder = 1 - k" z. `" _. ^
Else - U8 I* r% _  q! n0 i
deleteAFolder = -1 8 M4 Y, ~3 w$ X; K8 |0 N5 T
End if + D' [- ]5 Q$ P: T! q6 _+ ]' s, D% r
End Function
7 ^) L, E% Q) S$ z  {5 }) Z" x6 u
'显示目录列表
& |! ^6 |3 [1 I6 K# @+ SPublic Function ShowFolderList(FolderSpec)
5 {, A5 _/ H; w. T3 J& NDim f, f1, fc, s 5 y7 }2 G7 ^& ?& K( v
If ReportFolderStatus(FolderSpec) = 1 Then 4 W; o6 ^# q8 W$ n
Set f = objFSO.GetFolder(FolderSpec)
3 f1 J- G5 P3 [, {, @( d( [Set fc = f.SubFolders
9 u# ?5 d) B; d* [For Each f1 in fc
* g2 u! i9 k: x& h, h4 B, e0 rs = s & f1.name # q( i) ~. v# Z2 [6 V+ u
s = s & "|"
/ [4 F) E  `+ `. g  I3 _3 N. Y1 SNext & v. x. i. H, m6 P8 W7 P6 @
ShowFolderList = s * R0 a; q6 _  _" Y
Else
+ e6 J* c$ H/ i: V. @0 b% b& v6 z3 KShowFolderList = -1 0 \- J- Y1 ]& a& h
End if
3 S/ C. ^* k- T7 S0 Y2 L8 P5 y! Y; CEnd Function
+ K7 _8 l) W+ v8 I9 x* h
4 V) p% }. g7 O+ w0 {. x2 k& }'目录复制
& j- A  k. u: @) MPublic Function CopyAFolder(SourceFolder,DestinationFolder)
9 O" r) q& l2 p! x+ v9 D9 v! ?4 m1 RobjFSO.CopyFolder SourceFolder,DestinationFolder # A* b, R: w6 ~) X$ c
CopyAFolder = 1
5 z) F0 q* c. H% l5 qCopyAFolder = -1
2 A% G  K$ T  o4 L' h0 tEnd Function ) Y: R  z! |+ J; A, y; [0 u0 ^
: P6 c# q6 Q" j. S. b
  n4 x& O5 K8 _- B! m! q
'目录进行移动 % H; {) O% U) g& S) g, q
Public Function MoveAFolder(SourcePath,DestinationPath)
: F6 I7 W- b6 Q; s+ j: \If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
1 ^$ h) f2 Z1 W" k9 ?. X) iobjFSO.MoveFolder SourcePath, DestinationPath , B9 ?9 P- F, Z5 G/ q+ ^2 Q
MoveAFolder = 1 ) P/ ~7 E/ R+ t, H- J/ j! a
Else
5 j0 v* x8 F3 AMoveAFolder = -1 & s5 a9 S+ Z5 r, }  }5 A
End if
% C$ x' N5 x3 j, p9 z( f6 E, gEnd Function 8 D+ R) p) X! U5 i' Q
7 _0 ?, \  Z7 G6 S& L3 o- l) @  I6 i' j: ~
'判断目录是否存在 4 N/ f/ a  p3 w: L7 J
Public Function ReportFolderStatus(fldr)
0 ]3 f" I8 h5 G4 c, Y4 _8 xDim msg
* [4 X* q0 Y' K+ c! K! M. f: tmsg = -1 / s) b- n" r) h; B' P7 K# n: L
If (objFSO.FolderExists(fldr)) Then ' D# j: ?# V" i5 ]3 k* e* }
msg = 1 $ P- V, N  y  z1 W4 J0 N: z1 J( K
Else 4 a5 E9 f" Z1 O* ^9 {# l) u, v
msg = -1
$ L, q) a0 A; D/ M4 \$ CEnd If
8 \& r& S- V- a8 N6 Q4 QReportFolderStatus = msg 7 E! A% B# n  P, G  Y, I. [' ~
End Function 6 i  @" q* [! T; k/ ^- Y
! n2 F+ ]# O1 w1 o3 ^/ f! N
'目录创建时信息
4 K4 ]& g0 A% D1 Q6 p4 ePublic Function ShowFolderAccessInfo(FolderName,InfoType)
* r& \* y  m: {'//功能:显示目录创建时信息 ) j4 u  t: h$ g( `/ {
'//形参:目录名,信息类别
, F, G/ L$ ]' m% G'// 1 -----创建时间 ' V& [% E, [7 D2 A" O
'// 2 -----上次访问时间 ' U1 t8 J) @& u. x! M4 s
'// 3 -----上次修改时间
! n$ j/ a* N$ c/ X6 q0 A( R'// 4 -----目录路径 $ \* t% ^0 _, P$ Q( g6 V) j  j
'// 5 -----目录名称
8 B, ?" x( u7 Y7 e'// 6 -----目录类型 7 m( P  N; u& f) h  H4 a2 {! `
'// 7 -----目录大小 9 v+ a! m% o3 g$ H. B' H
'// 8 -----父目录
/ M+ r& W5 `  N2 n( w'// 9 -----根目录
" W2 J6 v- N6 f9 ]Dim f, s
; ^& H$ p* k  ^5 E1 IIf ReportFolderStatus(FolderName) = 1 then
6 V$ q0 x' t# {/ wSet f = objFSO.GetFolder(FolderName) & A" N: s9 M2 h/ t) @
select Case InfoType ! R  ^/ W: Z( n
Case 1 s = f.Datecreated 6 ~0 z# P: n: P
Case 2 s = f.DateLastAccessed
+ A) [. G6 L0 d" X/ \8 |$ oCase 3 s = f.DateLastModified 8 T5 ]% x. W+ v7 e6 O) K
Case 4 s = f.Path
- N- Y) v: N" v6 {Case 5 s = f.Name
& {9 w. j+ ~' r* w! Q) RCase 6 s = f.Type
8 ]  j- e8 l9 w4 s9 Y) `Case 7 s = f.Size
+ ^, T3 ?+ \7 R8 j' v0 ACase 8 s = f.ParentFolder / g% G, k3 N3 F  P
Case 9 s = f.RootFolder
5 S. S/ G4 M7 G, \End select 3 U. J7 J& O4 ?; h' h! K3 w& _2 G
ShowFolderAccessInfo = s
# k1 _* F1 j. K8 K0 l. x( VELse
& V. D/ q- C8 P# d5 bShowFolderAccessInfo = -1 ! |5 |6 P3 p7 {  Z
End if $ j! A( |% q8 T8 }9 z. Z# D
End Function
6 ^5 f+ i: o/ q% y# q! @, L* ~; ]. n5 T% Q% w/ j5 u
'遍历目录
/ z( a9 X% [3 \8 \Public Function DisplayLevelDepth(pathspec)
0 ~+ X2 p4 C4 Y, z: EDim f, n ,Path - p3 j9 X: x/ o. V% h7 W
Set f = objFSO.GetFolder(pathspec) 0 h4 F$ |8 h. h8 z3 v8 P
If f.IsRootFolder Then + P* f6 [" P  F7 x; ~9 J* n
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
5 h' ]0 r/ y& J/ v" c# I. WElse
+ m( t  R0 a3 r% J$ P( DDo Until f.IsRootFolder 3 f" k1 x7 y! p) d. y
Path = Path & f.Name &"<br>" ( ?% @) C3 i! b: J: L1 r! j1 S- d
Set f = f.ParentFolder - L# |% ~' p. i! s
n = n + 1
. Q# s/ C, o: ?. u6 e' v& FLoop / r, u' V, l/ h. I
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path " r" n3 e5 H* o& e8 A8 b
End If + f. c: _* L" Z  b+ i' r! F" G$ J. E# R
End Function ) ~7 g/ f' h' R5 [7 d

/ b. l5 }$ y" Z1 N* o2 J& ?'========磁盘操作======== 5 {* g0 D+ f7 X1 p! h
'驱动器是否存在? * G. h7 Y0 J: K3 }  c
Public Function ReportDriveStatus(drv)
" W3 h5 {2 z& n% ~+ O1 ]+ tDim msg , }' h  P# I' T- g1 E) _: b
msg = -1 4 d7 W/ _+ H. t, Y0 D$ e* I
If objFSO.DriveExists(drv) Then
* R$ K( o+ I; Tmsg = 1 0 C$ F) p' c8 g* }- I& F$ p
Else
/ ~. v0 E5 H. ^2 K6 ?, A# }0 F- B6 _msg = -1 ; [/ `9 w8 E' j" v4 K! K
End If - Q' o& |! X0 E) M; I4 c
ReportDriveStatus = msg # ~3 i1 {3 L9 Z" }! s( B
End Function
6 q$ L5 p' s! M/ i" |
! G" L  ]& `2 }, h$ q5 r'可用的返回类型包括 FAT、NTFS 和 CDFS。 - G3 E. z' U/ E  i0 Z! t. ^0 N8 x8 R
Public Function ShowFileSystemType(drvspec)
" ]# ]1 A! D) M1 j+ Q7 I& {Dim d
! G; ~( ?  U2 r% p- ^4 ~: sIf ReportDriveStatus(drvspec) = 1 Then
4 _( W7 i8 c5 [" y* RSet d = objFSO.GetDrive(drvspec)
1 s$ r/ ?! r6 Y  tShowFileSystemType = d.FileSystem 6 x( u8 ]) K7 _6 z5 @
ELse
+ u& e, X$ g* D" P) c5 H/ X* P7 C3 pShowFileSystemType = -1 5 }- \2 y  J* _% ?# C6 ?
End if . N# p8 o& S3 e, r7 \! I
End Function
. ]& N" D1 G, hEnd Class
$ w) v5 E( h5 U. R4 _; _) r5 o' B%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

GMT+8, 2026-9-22 01:48 , Processed in 0.021230 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部