【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

威望
9084
在线时间
1242 小时
金币
6984
贡献
300
存款
1660001
最后登录
2026-5-10
注册时间
2006-5-10
帖子
1840
精华
6
积分
15415
阅读权限
200
UID
10

论坛元老 网络高手

跳转到指定楼层
1
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全& f! W8 g2 p1 R" F! p
<%
4 S+ U" A' K& T: w4 W( aClass Cls_FSO 2 s8 D3 ~# F, @9 L7 d
Public objFSO
8 B1 q7 ^" g9 }- `% c, X' iPrivate Sub Class_Initialize()
: z. L4 X) P( U4 wSet objFSO = Server.CreateObject("Scripting.FileSystemObject") 6 Q1 C3 d& c  L8 x  z; i& H
End Sub
. C2 ]3 W+ j, q6 QPrivate Sub class_terminate()
) V$ [. m' W) f8 C# I' u0 LSet objFSO = Nothing * L4 G7 L3 U2 c& ^0 b
End Sub
' I  Q7 q0 y8 H( W" n. U+ \. M1 S/ X! g' \' t
'=======文件操作======== . ~  h  Q6 r. k1 \( Y* D2 g+ @7 {
'取文件大小 0 ~' n( y0 E0 w+ H4 }9 ^( }. ]
Public Function GetFileSize(FileName)
& K) d- b$ P7 }, l2 f) c' e" SDim f 0 s; ?1 P% E8 f' }; q' D- R
If ReportFileStatus(FileName) = 1 Then & |# `" H3 ~0 x, T4 B
Set f = objFSO.Getfile(FileName)
; V! w4 H( I2 s, L. AGetFileSize = f.Size
% r' j) x! V8 H7 eElse
) E8 M$ r+ L& J6 D& VGetFileSize = -1
% J% K2 M( A- x/ U8 R4 @) `. ]End if
2 U2 g& ]+ T* X7 e0 R0 rEnd Function 9 @' z( x3 X4 q3 Q7 P6 S
5 L' f" s8 s- ?
'文件删除
1 f  w+ z$ W; y; d+ c7 [( wPublic Function deleteAFile(FileSpec) $ y+ _: K& n5 p* a
If ReportFileStatus(FileSpec) = 1 Then
* t0 e, l) u0 o5 N  r: PobjFSO.deleteFile(FileSpec)
$ n( G7 ?& z( r- X' \# q" w. O( jdeleteAFile = 1
. o3 J0 v; F! NElse 6 M  a" d' U' d3 }& w
deleteAFile = -1
5 J( y* b5 {+ w1 ]; xEnd if
2 m! j6 ?/ C6 S' R. l( q) e8 p5 ?End Function 4 D# ~# X3 M5 W( s. q# R; w
( N7 N1 @! O  K- h& N' T) a
'显示文件列表
( \$ X$ [: _5 \  ]  x8 J# QPublic Function ShowFileList(FolderSpec) " D% j+ h& X2 |5 t0 O  N! y+ Y, X
Dim f, f1, fc, s
# n% c1 p9 u$ m7 r  vIf ReportFolderStatus(FolderSpec) = 1 Then
% d. R! M# K5 h, W4 A- lSet f = objFSO.GetFolder(FolderSpec) ) s- y; i/ I. I; U4 e, I
Set fc = f.Files 3 `! m' C1 U. u/ z
For Each f1 in fc 7 v0 {2 Y! ^+ \3 |' X7 l
s = s & f1.name
1 a% l2 J2 [. F# m+ x4 T  e/ w0 Ps = s & "|" : x8 k4 V; ~: Y9 |2 ~
Next : P; R' P) S% d: B% v* N' V
ShowFileList = s
6 o. P$ X7 J& bElse
, v% S) Z% s* O! rShowFileList = -1
4 x1 U# @( P; K- B4 b6 bEnd if 9 p& Y9 D$ ?1 \
End Function * R8 I! ?- x0 g  |! d! K" Z

7 q! l# t3 F( V: X4 o3 l'文件复制
6 O" Z9 o: q$ V' pPublic Function CopyAFile(SourceFile, DestinationFile) 5 f) O( u- O! f; d
Dim MyFile 8 [8 f, r, F  e8 r& G0 B8 b
If ReportFileStatus(SourceFile) = 1 Then & w3 V7 R' m6 l3 h. Y
Set MyFile = objFSO.GetFile(SourceFile) ; G5 s2 l! q8 C* [7 n' k8 Y8 ?
MyFile.Copy (DestinationFile) # @! c) Y# f% C; Y  f7 O6 f- \
CopyAFile = 1   y" D2 i& {6 b0 R7 k7 Z- k  f
Else
0 @6 ~4 a& z& E; O# j7 SCopyAFile = -1
' u0 v) T% Z4 I& y, o, s6 oEnd if * U1 H1 @! N2 s: h0 w7 k( k8 a6 x
End Function
( T, G  k1 t: b# w+ L
3 d7 p* m& \) S  _0 d% k, o/ w'文件移动
, o! P$ [9 H1 GPublic Function MoveAFile(SourceFile,DestinationFile) ! c+ y; G) C1 H
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then ! M# Z6 L3 }7 ^& T+ f
objFSO.MoveFile SourceFile,DestinationFileORPath + g2 |( B( {6 W. T. y, h5 h. K+ i* T
MoveAFile = 1
, b! q3 L# O- L8 _; w7 V) Q) eElse
6 x* i- N) U. g$ h; sMoveAFile = -1 : A+ V0 \% n6 P+ Y+ o% Z# E6 z! q5 _0 V
End if 7 f+ T8 w5 V; W2 `- C4 |7 ]5 k
End Function
% i6 q. c; X' L) Y& I+ n& }; J: M0 P, D% P. F5 Z* s! M
'文件是否存在? ' K: [. }! m, T
Public Function ReportFileStatus(FileName)
* B  z7 c& R: L2 ]! F: K6 H1 fDim msg
6 r5 \) X$ a- Tmsg = -1
3 b8 \2 R+ v, t" Y0 ?2 x7 rIf (objFSO.FileExists(FileName)) Then
9 \  q# ^% E5 V* k6 B% x) xmsg = 1 - V, B7 S* I1 q. x$ x
Else 8 `7 @/ P) l/ l! R
msg = -1 0 n* n( _+ x( F. g, O2 I/ d
End If
& S! e! E$ P( j+ b+ H9 V8 \ReportFileStatus = msg ' }: f" Z2 C' S( l9 E7 d  ~
End Function
; P5 C2 X2 L0 G6 F- N
  \6 B, O+ w! E0 G5 p; N* ['文件创建日期 5 ]; [1 E. X; I4 m2 }$ y
Public Function ShowDatecreated(FileSpec)
* A2 ^+ V- ?5 X4 CDim f 7 [) V- q" H- d
If ReportFileStatus(FileSpec) = 1 Then " B# [# x- P  H5 u1 G. Q
Set f = objFSO.GetFile(FileSpec) % `7 t( @9 X8 [4 }/ s& {
ShowDatecreated = f.Datecreated " m0 C$ H% L9 L  x2 }
Else
% t; F" t$ [6 B  R! e5 z8 vShowDatecreated = -1 , J/ ^, O5 N2 l* k1 T7 Q, i& d$ u2 ]
End if
* b5 o" _+ R$ A$ Z( ?4 Z9 L; EEnd Function
9 p( ^0 y% I" v2 y! k7 c4 J7 e6 ?# h9 o" D- Y
'文件属性
2 E2 [! S. @' E. g6 y5 V$ Z( y  _Public Function GetAttributes(FileName) * s7 p- w- x; q1 s4 k3 c
Dim f
5 J  q* ?8 w0 U. ^# \Dim strFileAttributes
2 [* ?; R9 D4 r7 G9 D6 }If ReportFileStatus(FileName) = 1 Then
2 |7 o" C. s& a3 |. h# w$ ~Set f = objFSO.GetFile(FileName)
  w6 V0 U5 p! M0 B+ Y& lselect Case f.attributes 2 G1 H7 x9 J- i, Q& g
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
! h+ o5 x: p1 z, w5 ?Case 1 strFileAttributes = "只读文件。可读写。 "
  r& g, v8 u0 U! U7 B+ W' pCase 2 strFileAttributes = "隐藏文件。可读写。 " ; l1 {3 B9 B" J* k% b
Case 4 strFileAttributes = "系统文件。可读写。 " % a7 @! B0 i( s/ R5 b( p3 x- g
Case 16 strFileAttributes = "文件夹或目录。只读。 "
# {9 c! C' r! T2 `Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " - S, W: t. t9 j' U7 C. ^
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " 1 C3 `) P2 Y, s- F( }( ^
Case 2048 strFileAttributes = " 压缩文件。只读。" ' _5 K( E. i" M" P
End select ( \  E3 b+ ?/ Q4 Y7 {
GetAttributes = strFileAttributes
3 i/ F% S! U2 J7 `  HElse , l$ @" e5 |% ?/ A5 a# h: H0 n
GetAttributes = -1 + i) {' E. k( @4 v& ]& ?2 ?( d
End if
+ ~1 _. |7 M0 T- }$ [9 S) G* oEnd Function
, z- V8 E- F: _
; u) ~% y! _$ k4 e- r  ]  K5 q'最后一次访问/最后一次修改时间
9 X- K' M( ^# Z4 u. bPublic Function ShowFileAccessInfo(FileName,InfoType)
+ u4 I9 M( @* |, x! j'//功能:显示文件创建时信息
- a$ v: f  I+ b3 }3 b'//形参:文件名,信息类别
2 O- q7 x9 z; [* l- E'// 1 -----创建时间 ! Q& S: R/ O) u( u: z. Z! Q" o
'// 2 -----上次访问时间 8 }) s7 ?0 n7 R8 P. P0 s
'// 3 -----上次修改时间
, V+ r: e' j, u0 j8 K'// 4 -----文件路径 " r# B$ C; g& W; K
'// 5 -----文件名称
  H* i  M3 s, Q6 M'// 6 -----文件类型 / U7 {3 N0 U* c" b
'// 7 -----文件大小 5 l1 H# D- o3 m" K' \
'// 8 -----父目录
) {5 P, z8 d, K. G" I% Q'// 9 -----根目录 # p# }" s0 {) k- X  r  U
Dim f, s
, N& T8 T  a& F- G3 _) rIf ReportFileStatus(FileName) = 1 then
9 X# u3 k5 H5 ?/ ^5 z( L' uSet f = objFSO.GetFile(FileName)
* I5 e2 _$ x$ f& @# l; a% n3 sselect Case InfoType 2 t& Y; ?- @3 ?. L
Case 1 s = f.Datecreated
" @/ H, c9 P8 [  [( U- \9 {Case 2 s = f.DateLastAccessed & K. {8 b: e7 k. N+ v% t0 e
Case 3 s = f.DateLastModified ; |4 b8 z# A& Y$ X0 s
Case 4 s = f.Path
+ @( U1 M  [2 iCase 5 s = f.Name
8 A- W% E9 n! K# E. aCase 6 s = f.Type " d: A, E/ u* M. v+ W6 d
Case 7 s = f.Size
. X/ r- X) H( B: h! _Case 8 s = f.ParentFolder 7 |7 N6 ~6 B- w9 |' b
Case 9 s = f.RootFolder
1 L2 }! s6 h) U2 G. Z+ M* DEnd select ! ]9 N$ U5 O- L; g4 I1 d1 [+ `
ShowFileAccessInfo = s
9 p2 p) L. V( S& [) e$ P1 oELse
5 h( n! a4 f' J, t. @ShowFileAccessInfo = -1 7 P' g/ T1 k. i. f: Z7 b- |
End if ) C# c* a; A6 K9 m+ x, I4 ~
End Function
& ^3 A# Y& i) Q0 O
/ C2 c( L5 [3 h! d- F'写文本文件
3 G% X! J5 B6 W% ^/ ^) RPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
0 S5 E  v; [* i7 ^! EConst ForReading = 1, ForWriting = 2 , ForAppending = 8
$ n! \! w5 O9 R9 V8 j; @- SDim f, m 0 S- c7 _2 }: E; j
select Case WriteORAppendType
1 n$ m  A2 |6 j  PCase 1: '文件进行写操作
! X' ~9 C+ V$ @! V- HSet f = objFSO.OpenTextFile(FileName, ForWriting, True)
! y* Q$ |! T% hf.Write TextStr ' u6 w0 R2 w7 V4 z5 G
f.Close
+ u* H5 y7 Q) C. J7 jIf ReportFileStatus(FileName) = 1 then % v" A# |. W$ ~3 b0 j6 b9 d3 |$ E
WriteTxtFile = 1
1 X* ~  G- ^7 YElse / p" J  g4 o: z4 ?, @
WriteTxtFile = -1 & ^5 r( ?% l" L9 j
End if
  k' z1 P4 U; h' H" s$ ?" R, ~# {" L; wCase 2: '文件末尾进行写操作 ! ~6 T" q$ G9 u# A% c& R/ P' v9 \
If ReportFileStatus(FileName) = 1 then
: Q( s9 I1 E3 L9 d3 [1 \" l5 pSet f = objFSO.OpenTextFile(FileName, ForAppending)
0 c& Y. |9 b, A  P0 h# \+ p- `* Z' Of.Write TextStr 4 ~! H* f1 s8 w. K4 E- T2 v
f.Close 9 r8 m0 D& z2 {  l5 l" r" q
WriteTxtFile = 1 % @5 L4 B1 y( |1 Z) J, R
Else
0 d1 f2 ?% d) V! q3 M" aWriteTxtFile = -1
" u7 m8 ^, N' f" a1 `/ B! @" VEnd if
1 D: O6 a  d0 Q& Q# C  BEnd select 4 t3 I- L# ~8 Q/ f% u' C4 I
End Function ! z. M' G3 W7 ?$ C

. P/ H! _3 q. ~$ b" w. j'读文本文件
9 o6 g2 t: f- r  \Public Function ReadTxtFile(FileName)
) z3 Q$ X2 I& ]Const ForReading = 1, ForWriting = 2 + y4 E$ U: x% D* W, s
Dim f, m
  W) k. U" ]/ t+ M* tIf ReportFileStatus(FileName) = 1 then - y* F8 f: j$ W. d+ Z7 C
Set f = objFSO.OpenTextFile(FileName, ForReading) ) U4 _! {3 G2 }" \% E9 L. o
m = f.ReadLine
& H8 f( O3 T$ t) z" WReadTxtFile = m
0 {* u! d" P0 of.Close - Z  }! _' W/ h$ s- I5 ~" Y
Else : I  l; l5 f, M3 z6 Z
ReadTxtFile = -1
- y1 m  o* p/ d  A+ FEnd if 0 R5 y6 v6 R9 x( P: e. e9 a+ }
End Function
5 ?! E, s1 Q5 Q% e( |/ B
, u6 G9 R' f, f+ v'建立文本文件 0 m3 E% Q( ?3 m# Y5 k  g4 V
6 m7 r. E. Z4 e6 a* Z# {. H+ g3 j+ K+ |
'=======目录操作======== 8 t( P" }: k- m; F+ d3 j) L# q
'取目录大小
9 O5 R0 z  S* k5 [. jPublic Function GetFolderSize(FolderName)
+ o, k: e6 I7 i* T) zDim f 5 A( S& w& b! B" }4 w- z! O
If ReportFolderStatus(FolderName) = 1 Then & f4 o0 R' A' f+ q/ P5 F
Set f = objFSO.GetFolder(FolderName) 2 S+ l+ ~$ J; z6 W5 S
GetFolderSize = f.Size 2 c/ @- L9 r8 }: }, r1 m1 b1 g
Else
3 E6 h5 J7 C1 `4 y; m, `GetFolderSize = -1
) K) }6 i& A, S$ O+ N+ h: s& PEnd if
- |$ h2 k4 l, e$ s; Q. CEnd Function
! Y. ~& t1 {+ H# Y0 `+ H% `( _4 U" V% Y8 `
'创建的文件夹 + l% v* {4 o5 L8 K; [
Public Function createFolderDemo(FolderName)
9 G9 l: k$ d5 z6 E2 Y- dDim f : a' c- p6 `  u* i
If ReportFolderStatus(Folderspec) = 1 Then . Y3 B) X9 w5 D/ f0 I8 O
createFolderDemo = -1 ) R/ h. W! j. P! H/ p
Else 4 ^1 W9 E) {7 d% G! T$ w
Set f = objFSO.createFolder(FolderName) 0 r- y7 v6 M/ G9 R* M, Z
createFolderDemo = 1
* r1 U! W+ A, c% w- V& KEnd if
1 n$ {1 D$ Q3 W& ~End Function
; q( c; J* n1 U/ i+ z& `+ Z# x2 J+ ]3 s0 Q. O& O% M
'目录删除
* B9 k0 t; r: H. X) h1 Y" mPublic Function deleteAFolder(Folderspec)
, e! d) D0 H% g7 ]9 w: P& k" MResponse.write Folderspec   W& E0 T; I: I) w; D8 U( A( g4 J
If ReportFolderStatus(Folderspec) = 1 Then
3 o4 Y; Z) m/ Q/ A% fobjFSO.deleteFolder (Folderspec)
# t" p  e0 R6 L9 C3 h* MdeleteAFolder = 1 . X2 d* T6 {& ~+ s
Else
$ E& J5 u: m9 m! b9 FdeleteAFolder = -1
, y) U! g* m8 {0 R2 vEnd if
4 L- a  |9 O& e6 S) }$ PEnd Function 8 C6 f% f" m) ~1 A

) u2 q; _+ `6 ~* T+ H: l1 r6 o'显示目录列表
8 ~4 E/ E7 L4 X3 i7 q" \Public Function ShowFolderList(FolderSpec) 7 t7 \. O' F, z, u# o
Dim f, f1, fc, s ! y9 J' P6 g0 L1 G3 A
If ReportFolderStatus(FolderSpec) = 1 Then 7 C2 ]0 @3 ~2 T2 i
Set f = objFSO.GetFolder(FolderSpec) 0 A8 K1 B' ]- m9 {% j
Set fc = f.SubFolders # H% I" e* l4 W" q
For Each f1 in fc 8 ]- w2 S' {8 I, M- j
s = s & f1.name
" \2 X" i5 {8 F2 Zs = s & "|"
9 U( O5 c, B4 \* F7 z5 FNext
" `! A- t, A- y  V( n% j; [ShowFolderList = s : {, G; x, `& K7 n" B% R) |
Else
7 R5 h5 u; t. A4 b% sShowFolderList = -1 , l7 X0 D; K# k) m
End if
" }; C. N; z$ ]8 hEnd Function
% Y3 u. }! f6 z5 x8 m/ f7 Q
; a+ {2 o& e4 e( R2 t. O/ ?: c. l4 B'目录复制
2 w8 Z2 u$ L9 hPublic Function CopyAFolder(SourceFolder,DestinationFolder)
. B. R% z& c/ p) l3 }- TobjFSO.CopyFolder SourceFolder,DestinationFolder
- [, a$ k, [8 I' I- G: d0 j3 S. T! sCopyAFolder = 1
, x+ ~+ S* y# n! X5 U" c4 XCopyAFolder = -1
  l4 V# C- g0 Y5 i, p8 I& }End Function
3 H( J$ Z6 s- p2 z' k& v" E$ Q# W
/ o9 m' k" a. w; E" G  S- D
'目录进行移动
) i' @0 u/ g% \Public Function MoveAFolder(SourcePath,DestinationPath)
; s" R* \/ l. y  I7 gIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then * o& h" u7 n$ U! ]  `
objFSO.MoveFolder SourcePath, DestinationPath 3 _% Z5 ^( `& t
MoveAFolder = 1 - ?6 @2 L/ l0 A4 i" e, k9 Z5 q* E& E
Else
6 {7 N" n7 T/ n) TMoveAFolder = -1 $ l; A: ^6 U6 S0 O; {
End if ! @) j  o" P8 {5 X0 ^2 @
End Function
* @# K# E" B3 A" b6 r) y' |( g; G: M/ k5 U, U. Q( C# x
'判断目录是否存在
6 x3 _: u! u; l& w; IPublic Function ReportFolderStatus(fldr) + t/ C( P% {3 E4 f' `- E; v- q
Dim msg 7 ~) B+ g; N* w- |! u
msg = -1 & \$ ~: O% L. x4 ]- |! }
If (objFSO.FolderExists(fldr)) Then
+ N- }# }- a+ rmsg = 1
; `  |2 T+ J7 g1 B4 @9 ^! k  BElse
5 F; V+ f# l  m0 U1 {, X1 G8 {msg = -1 6 p( E" i! j# Q9 \+ e+ P, x
End If
7 Y8 [1 u8 b. p. Y$ s" d4 D  X" kReportFolderStatus = msg ' p1 w- h  l  B( r" Q
End Function
, p, S. Q7 o( D& k9 s4 \. x( q  A1 \9 E2 Z4 O+ a9 y
'目录创建时信息
; Z6 t, ], f& w) MPublic Function ShowFolderAccessInfo(FolderName,InfoType) - a* i9 D& ?. J  W/ P$ i
'//功能:显示目录创建时信息 8 n$ w' l2 n/ {3 g, J/ [
'//形参:目录名,信息类别 5 s- ]! {8 j5 |5 X
'// 1 -----创建时间
* T' t1 H4 W8 B% [, ?'// 2 -----上次访问时间 4 w+ z6 V+ H) ?6 q- A) ~9 ?; M
'// 3 -----上次修改时间 5 H% r6 l& ]7 Z$ u3 R
'// 4 -----目录路径 3 e* s3 n+ E7 y, j/ r
'// 5 -----目录名称 " f3 K+ _5 C+ J% d7 O, D
'// 6 -----目录类型 7 ^+ c$ C" B' _* S  ?
'// 7 -----目录大小
7 [5 D- g8 q# S3 \7 j0 u'// 8 -----父目录 9 L& E' ]0 r/ I
'// 9 -----根目录 ) N+ H+ M* n1 F; @% w
Dim f, s
7 i7 v6 c- P2 a2 }# EIf ReportFolderStatus(FolderName) = 1 then
0 v/ B4 m$ W# f1 o* M8 xSet f = objFSO.GetFolder(FolderName) # `$ ?$ q! r+ o( j
select Case InfoType , ~! b) u  U4 h" s6 l+ k2 W- N
Case 1 s = f.Datecreated
; \9 ]( d9 G' e2 P  u" ~; }( lCase 2 s = f.DateLastAccessed
5 M4 M4 R( J' P6 k# G& \Case 3 s = f.DateLastModified , F# k2 g  m0 {* L6 ?! M" H
Case 4 s = f.Path
# X% \) ^  M+ y5 _& a1 kCase 5 s = f.Name 7 f& n! ]7 k) H( A7 p
Case 6 s = f.Type
) D$ Z' S. t* h5 }Case 7 s = f.Size
( @% g; N- q$ P/ JCase 8 s = f.ParentFolder $ E* C& Q: D/ `
Case 9 s = f.RootFolder 7 V: l7 W+ s3 h" j
End select # y! k* ^+ N" s' x. P9 G
ShowFolderAccessInfo = s 9 Z: O- I  n2 T' d/ O
ELse
6 z& ^2 K5 X( V* A) ~8 G) }ShowFolderAccessInfo = -1 . o  ?( e6 Z% w+ e- p1 w. ^- E( H
End if
: ^. M/ B" N  BEnd Function
! ?" P5 r: h/ c, f' t- n& E: c' {6 z
'遍历目录 * W$ S* M' _/ H$ C& T
Public Function DisplayLevelDepth(pathspec) / N$ s8 t3 l1 l" N- T1 y/ ?( d
Dim f, n ,Path 6 c' A- U6 ~2 f( b7 P8 _! n! u
Set f = objFSO.GetFolder(pathspec) 3 }1 L( M, ^( U" \' o4 l' _
If f.IsRootFolder Then
6 n! j- N7 w0 X6 y8 RDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
6 u1 w8 {/ o1 ?- S  C) Y/ `Else
" h2 h8 S# _2 x) ]: DDo Until f.IsRootFolder
. _" k" B/ m, ^# r" V. w% f4 _Path = Path & f.Name &"<br>"
) d$ G, y- c" LSet f = f.ParentFolder
  {/ V* |1 z) U+ |$ w  en = n + 1
. X* n, Z$ j5 D$ O- q- NLoop 1 e4 _- t; b7 Y1 ]
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path . `; I5 }9 D3 O! Y9 X  t
End If
0 X1 t$ g0 R  O' |$ NEnd Function # ^9 T# H4 i4 b9 A: r

$ V/ y6 U; C# e# z0 ]8 l'========磁盘操作======== ; t" @4 T* @8 f2 W; g
'驱动器是否存在? 9 f2 ?* _' ^8 [$ `  _! E
Public Function ReportDriveStatus(drv) $ A* n, B8 o9 o; m, \2 M+ P) f  l
Dim msg
7 c3 _4 K9 L" u2 M& E& R( gmsg = -1
" B% S9 e- s5 S  ^* r2 u  ^If objFSO.DriveExists(drv) Then 5 Z+ U5 T5 g7 b5 @3 V: m1 c
msg = 1
% T4 D6 n: G* HElse
4 `' ^& _( k4 i# K# e* Q( B4 pmsg = -1
+ N1 J! s" i' s& h/ r! v- R7 IEnd If
/ W# }8 t8 r* D/ S$ ^  dReportDriveStatus = msg
. q  B0 p6 Z2 k. t3 G# m1 JEnd Function . R0 q8 f, H: h$ ?) n
2 \. K4 a5 h% v/ X; U
'可用的返回类型包括 FAT、NTFS 和 CDFS。 " Y  L! X+ h0 Z9 ~1 j2 i3 {% e
Public Function ShowFileSystemType(drvspec) ; h: [+ M  `! ?. K% `0 I
Dim d
7 {/ O' Q. R. q4 u/ i1 u# FIf ReportDriveStatus(drvspec) = 1 Then
2 F6 d+ z& H& l+ h) d/ ?- ]Set d = objFSO.GetDrive(drvspec) ) G0 _# a$ N! B  W
ShowFileSystemType = d.FileSystem
2 x# K- y. m/ o7 h- eELse
1 [4 a/ V5 Y8 \% `+ m6 F3 F* aShowFileSystemType = -1
9 A% a+ j* P' C9 i+ _End if + n' L0 Y; R5 r/ P) @
End Function
$ \- ]7 y0 f& r' _3 U7 C( a' A' {End Class 4 y  Z1 h" w0 s( d5 g- ?; ]& l
%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

个人业余电台:BI7ILX   守候频率:439.9625 -5 t88.5

您需要登录后才可以回帖 登录 | 立即加入

Archiver|手机版|【高州情】

GMT+8, 2026-5-10 17:04 , Processed in 0.026939 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部