【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

金币
7308
贡献
615
威望
9151
最后登录
2026-7-16
帖子
1875
积分
25896
UID
10

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

跳转到指定楼层
1
发表于 2011-8-17 12:38:09 |只看该作者 |正序浏览
ASP文件操作大全
9 x  @, N0 ]: `: T! c8 @<%
6 n2 k% U% i' w, V! H/ w  |$ ]4 B/ rClass Cls_FSO
8 P4 x6 Y, V$ APublic objFSO
9 U  b/ S6 U0 D$ p% ?2 HPrivate Sub Class_Initialize() . H5 T! p( v5 q0 O- |& M
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 8 a$ Z+ c  B& t- h+ h
End Sub 0 q* K# A$ I$ e, U4 x
Private Sub class_terminate() 1 P3 h4 a; s0 W! r. {+ q
Set objFSO = Nothing " ]2 M' W" A8 @
End Sub
3 V  D/ W' ]& u" v) A1 ~# L6 Q& [% ?: h+ {
'=======文件操作========
2 ]) Q% Y$ ^4 R  E1 c* L'取文件大小
, ?( b3 G% w- B) [2 ~$ W! ~Public Function GetFileSize(FileName)
% C. A( P2 L  z* PDim f
- Y9 H' a( g! L/ N- p. mIf ReportFileStatus(FileName) = 1 Then
8 N* e0 A7 ]9 ~! ySet f = objFSO.Getfile(FileName)
4 t% t3 O7 }$ b  e8 f- H4 p( [, pGetFileSize = f.Size
' u* k' ~! O: y! L* ~6 o6 HElse
: Z2 @; c0 G2 i+ I  k4 cGetFileSize = -1 $ g3 h' j" t* Q- P/ r. `
End if
6 t) v) P2 W( N" {1 iEnd Function
8 l5 Y" n  Q& |5 G
, `: O/ s; R) s'文件删除 ) \5 r# v! [% L( F' `
Public Function deleteAFile(FileSpec)
/ J9 c- Y9 }$ W7 hIf ReportFileStatus(FileSpec) = 1 Then
2 q7 {+ [( D+ g! ZobjFSO.deleteFile(FileSpec)
" }& K. s0 f8 L8 f. u. T& HdeleteAFile = 1
$ \2 k& u; R8 q1 S, V, n$ IElse
3 R7 t- B( c8 D9 n- X2 V8 kdeleteAFile = -1 0 a+ B7 g, q5 w2 z1 p  E- C1 Z
End if 0 R5 }& i1 \5 T, y4 A, C  q4 [
End Function
9 t. v7 G3 c& g2 C; |- K( ^' F- J2 H8 _/ ^7 ?1 k
'显示文件列表
$ N" N9 E  S  r( a/ p) V# b# s7 ]* BPublic Function ShowFileList(FolderSpec) 7 H3 U4 }6 T' W8 q' c; l
Dim f, f1, fc, s 5 _8 K9 z6 v9 i) a" E0 e
If ReportFolderStatus(FolderSpec) = 1 Then
/ {9 V& o# E/ D- r8 X! E' S# ?Set f = objFSO.GetFolder(FolderSpec) & A7 a* N. b( D1 j0 P) F& u
Set fc = f.Files
! U. |5 m5 d- y  k0 B$ jFor Each f1 in fc 3 R$ ~' y! B( `% l
s = s & f1.name
& f: ]4 s- r. ^* D! f0 E& }7 Ms = s & "|" + t* G% c/ J% |- m7 V2 ?
Next 0 X0 ^2 R2 n8 O7 H- |* z
ShowFileList = s
! T3 x2 e9 E: {" A7 w" `Else 6 V" k  f5 h) i- c: K
ShowFileList = -1
0 _5 v/ z- v; X- u) `End if
7 F, T/ {3 T$ g: pEnd Function
. [, v1 N7 S; H7 n; ^4 V6 s- ~; d9 ^9 P! y! ?8 R3 ?+ R- G- `! @3 @
'文件复制
; r1 O  S5 `, v2 ]$ ^Public Function CopyAFile(SourceFile, DestinationFile) - Z' c) ~* J0 |- ]6 U4 B! U
Dim MyFile
2 [2 l) S: N/ K, t( ?If ReportFileStatus(SourceFile) = 1 Then
, R( }+ Z1 F. sSet MyFile = objFSO.GetFile(SourceFile)
* G0 |' A  E' [7 c' `4 UMyFile.Copy (DestinationFile) . b' t. b) x" o& {% S; U
CopyAFile = 1 & O! Q: y* S! x% u+ y  P% F
Else
! h( O% g4 N5 g$ e1 U7 MCopyAFile = -1 + ]2 y) X$ j- l' B! p
End if $ f! J: s- O- P: w# h0 M/ F. q3 b
End Function
8 q: U, O9 |5 a3 E8 X- o- |. @$ K" s; y: `, S% p
'文件移动 ! U# j+ d1 M. [* c  J0 a% J
Public Function MoveAFile(SourceFile,DestinationFile)
+ j+ }/ u; _% K. f( n( GIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
1 i0 R( c6 g% @( w4 }3 D3 T- D4 UobjFSO.MoveFile SourceFile,DestinationFileORPath : h+ ?% y! T6 Z
MoveAFile = 1
7 b# X$ t; U+ u% o& Y" X( TElse 8 t( y7 H! g! ]7 @* Y
MoveAFile = -1
# h! R) S3 I9 z6 Q! L8 F5 e0 YEnd if & t0 {. A9 e/ j8 `
End Function
9 Y6 Q1 x) H0 {. `2 u: O5 m' }8 C1 j9 J& ~* b
'文件是否存在?
& b/ m  Y( c- KPublic Function ReportFileStatus(FileName)
. G! B9 N) o7 o+ p9 N3 I. c( B9 y5 ]Dim msg
8 i. o) a. Y! x- k! ^msg = -1
% \2 T: ^& |/ J6 H+ kIf (objFSO.FileExists(FileName)) Then
7 j2 M+ G' `' f" y3 {4 Z7 Imsg = 1
2 ]8 s/ N6 s1 lElse
5 M6 a7 y, b: \9 u: y7 Hmsg = -1 & m' Z- o: ?: I  W6 }& W$ r
End If 0 U2 v- f+ ~; |, n
ReportFileStatus = msg : Y' a0 T! z: w4 k
End Function 0 p% z# O( v4 h$ q
  ?" u5 m, S5 ^. W: s# N- X
'文件创建日期
* U- c+ }  m& ?# CPublic Function ShowDatecreated(FileSpec)
/ _" I  D0 |, l: d7 M0 gDim f 4 v) h6 W5 Z( J6 q4 I! b
If ReportFileStatus(FileSpec) = 1 Then
( @+ b5 r% }1 a5 ?Set f = objFSO.GetFile(FileSpec)
' k+ X) Z0 D/ z; G/ p( K9 XShowDatecreated = f.Datecreated
! U1 w8 r( M" cElse
. G* N4 @( v" H9 L9 U. f& e( SShowDatecreated = -1
% L7 M9 b% x- ]* ]4 oEnd if
) F) w! d/ a3 D3 \End Function
$ ?. q! W$ Q: R( d' K) r3 }. q4 r' f# z7 d0 U4 V
'文件属性 ! x; q$ t! i4 \, F* K
Public Function GetAttributes(FileName)
# d! J; g2 k. f6 l; g' t$ G  tDim f + O. P+ ~# W; v9 t. ]) h- {
Dim strFileAttributes - `' T* L2 J/ ^8 [
If ReportFileStatus(FileName) = 1 Then , a; ]4 K/ G: ]+ y. N3 @
Set f = objFSO.GetFile(FileName)
5 C% ]5 m$ h4 Q  F9 h, cselect Case f.attributes
/ c) ~7 E6 X, r/ f' E' qCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " & C! m( g6 U. _8 r: @: F$ N
Case 1 strFileAttributes = "只读文件。可读写。 " 8 {: r& n% ]3 E3 M
Case 2 strFileAttributes = "隐藏文件。可读写。 " 7 c. j% Y( m( M7 D; v$ L! J( _
Case 4 strFileAttributes = "系统文件。可读写。 " % {3 G' w3 a; E/ o' w( Y( N
Case 16 strFileAttributes = "文件夹或目录。只读。 "
  \# l! {9 L* T1 ^5 m0 vCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
" R1 W& b  y) L4 |) ^2 w: ECase 1024 strFileAttributes = "链接或快捷方式。只读。 "
( C3 V3 m3 X- BCase 2048 strFileAttributes = " 压缩文件。只读。" ; J3 w6 a  z4 [) R( d
End select
/ E: Q0 J6 ?3 O; nGetAttributes = strFileAttributes + D9 L/ ]6 h# _- G3 i
Else % J: L* J. }' G# E- t3 ^
GetAttributes = -1
4 B2 n/ q$ k& C% P1 gEnd if ! @$ l" [7 I$ L5 C, }
End Function
) Y4 A: y$ B4 q- T
4 z7 n/ I5 N5 D& Q'最后一次访问/最后一次修改时间
) @0 R7 f) h! P) ]5 p; }% a0 ~. nPublic Function ShowFileAccessInfo(FileName,InfoType) 6 x4 o+ ^7 j' u/ I+ w6 ^
'//功能:显示文件创建时信息 0 j# x0 F$ t3 v+ a; O
'//形参:文件名,信息类别 * p- |. w* t$ a' K" u8 L" i4 z
'// 1 -----创建时间
) R' H+ B# f: ]9 L'// 2 -----上次访问时间
  Y" e0 |5 D, ^0 `2 s) R3 e'// 3 -----上次修改时间
* h, M$ E1 H, @2 B  c3 k4 J: G'// 4 -----文件路径
) r: v8 Q( K% ~& M! r/ G'// 5 -----文件名称 : H. {% C& M7 U" u# y
'// 6 -----文件类型 $ b! ?. w& `( K/ a( ]
'// 7 -----文件大小
( t  q0 H( ]; S! p* j4 _: }'// 8 -----父目录
& J3 X1 Y! ^: z) v. E2 G'// 9 -----根目录
0 `) W- ]' X: CDim f, s
3 ?: P8 f! A* F5 i; {If ReportFileStatus(FileName) = 1 then 9 v* R, l6 p7 Q" _' I: u7 \
Set f = objFSO.GetFile(FileName) - {) J* L. d$ G' u3 _- `+ V
select Case InfoType
: E" r5 g. \5 ^- d. l/ f. LCase 1 s = f.Datecreated
$ d( T7 K, ]. W1 }Case 2 s = f.DateLastAccessed
7 [: K! b) r: a2 H- wCase 3 s = f.DateLastModified
, ]2 m6 Y1 z, Z6 c+ gCase 4 s = f.Path
4 P) c9 u/ J' cCase 5 s = f.Name
8 U4 m- R# C/ C! Q: U. K  j& FCase 6 s = f.Type , _2 `8 ]8 M. X* T
Case 7 s = f.Size * Q9 V7 [/ f- |, W
Case 8 s = f.ParentFolder
- U$ C% e, w- \* nCase 9 s = f.RootFolder
( b; l& N  O; X- k1 eEnd select : ~7 w( ~- T5 a3 O- `
ShowFileAccessInfo = s ' r9 L2 w+ z# a" P, D0 p
ELse * r! Z& O# G; j5 |' `
ShowFileAccessInfo = -1
8 w9 z$ u1 {9 i6 U- mEnd if
: G9 w4 |4 R8 [End Function
; }/ ~" [& v1 h6 S& ^" }# K
# e  n3 r, C; e( K1 N8 N( Q'写文本文件 + z$ H7 H/ v  g5 V1 `  z
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType) % I* `; H4 O& }: t9 c2 e
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
* H  ~5 Y* [' @/ D% a% UDim f, m - S9 @7 h8 W8 N* y6 n7 k+ |
select Case WriteORAppendType 6 |0 ?0 q% |( h3 u4 j& D8 N
Case 1: '文件进行写操作
% t7 I. Q& n. ^, a( I7 h/ ~; f0 VSet f = objFSO.OpenTextFile(FileName, ForWriting, True) ! X0 o8 |. ~2 i4 J: A' l; v6 J
f.Write TextStr 7 `# @3 A( L" F2 j/ H
f.Close
- x, L0 P9 \2 \% ~7 ^3 W3 m/ oIf ReportFileStatus(FileName) = 1 then
% B2 l3 w" Y; I' _# Y* bWriteTxtFile = 1
9 X* U8 Q8 M& v% ?Else
2 d) F3 i  J+ t( JWriteTxtFile = -1
* V  C, b: h( J- ]/ ~End if / M% j. \, N& [7 f! }5 |3 N3 ^
Case 2: '文件末尾进行写操作 6 A( }7 G7 D! V" M  T& a" K
If ReportFileStatus(FileName) = 1 then
& e7 m, g, s/ @# xSet f = objFSO.OpenTextFile(FileName, ForAppending)
* s4 i& v, X: A7 D) ^6 Sf.Write TextStr & a8 x& H1 {0 L
f.Close
% b+ V- z' v+ k, IWriteTxtFile = 1 ( O1 i" ^( O# v) u
Else
0 u+ J% @8 {3 ]. [7 aWriteTxtFile = -1 + A1 A' h) h9 f7 W5 ^
End if * c( q5 n/ L& k0 a3 ?7 ]
End select
( u7 R  Z9 t. ]6 m; P* _4 r5 wEnd Function / A" l7 h: Q. `6 w+ M- h( q* k; U+ N
' o- M7 o/ }( Z& D/ C7 k" J
'读文本文件 2 f% ]# v' J$ i# @4 h1 s8 R' ?
Public Function ReadTxtFile(FileName) 6 D1 s2 t* z& @9 M' |
Const ForReading = 1, ForWriting = 2
: Y% _# U% n1 I# n1 S# gDim f, m
. c0 s' g/ |( e9 NIf ReportFileStatus(FileName) = 1 then 2 R7 b+ _8 K% G+ D7 L$ i
Set f = objFSO.OpenTextFile(FileName, ForReading) 8 b' m8 J. W9 |
m = f.ReadLine ; u0 {) R6 B, X
ReadTxtFile = m 4 `2 j7 G! |7 w2 T  W; \+ ]  A
f.Close 9 r6 J1 U! i% _, |7 Y
Else
* N, `. ^' U- Z/ j+ N9 xReadTxtFile = -1 # a% Z( [; O, }+ m
End if ( u! r1 {  C* o- T% F
End Function
/ H9 b9 ?, q% h: K3 d
4 K2 g8 ~+ |5 I3 [0 Z% u! z) C'建立文本文件
7 P  T, m" d- K3 @1 a
# z* k) m  t% O'=======目录操作========
- ]% M( o4 ]/ B- v'取目录大小
9 h; {1 N' R! G1 uPublic Function GetFolderSize(FolderName)
! |6 }6 e4 `( }Dim f
* _' z1 m) o2 x2 J/ yIf ReportFolderStatus(FolderName) = 1 Then ) O3 M9 J3 p; x* A0 N( `
Set f = objFSO.GetFolder(FolderName)
1 N. Q  p( V  X1 Z( \GetFolderSize = f.Size
+ ^6 B/ A  _/ jElse & Q! W3 Q' X4 t# E; ~2 s- H$ Y# X
GetFolderSize = -1
, X0 A% l8 \* ]$ m! E& g* QEnd if
+ H% K7 h& ?3 Q/ T- E! b0 k" oEnd Function
) h! J1 O3 l7 Q  A+ G
# A7 `$ }6 C! u5 x5 B'创建的文件夹
. |, e* g8 j  x8 j. E" a9 D- uPublic Function createFolderDemo(FolderName) # _+ p% ]5 ~( t" A- d
Dim f * z7 L4 c1 M$ M2 M- ]
If ReportFolderStatus(Folderspec) = 1 Then
- C6 e5 ?! m. ^1 rcreateFolderDemo = -1 3 H# F" p1 F% N6 h
Else
( E) b! Y3 v6 G. rSet f = objFSO.createFolder(FolderName) ' w0 ?0 N8 j/ r, \& E
createFolderDemo = 1
& v: I$ Q. ^( B* i* }End if ; g1 j$ H; p- }9 ]3 ?0 E+ }; K2 L& C
End Function
7 F# V2 h$ K: n: g
+ `: `* e( _: s/ q2 m' p'目录删除   v" ]* Z! B7 y8 c9 w8 _& ]
Public Function deleteAFolder(Folderspec) 9 X# H# g2 @+ D( Y' S' Q- t
Response.write Folderspec 8 U9 o" S! o/ Y# t5 u
If ReportFolderStatus(Folderspec) = 1 Then 9 h- u% J2 P: P% A) I
objFSO.deleteFolder (Folderspec)
5 `$ t* r# d: k4 t* HdeleteAFolder = 1 4 e( K! e" @, g" d
Else , o, G- V8 h  Y7 Q! ^
deleteAFolder = -1   l$ p8 y0 g- c2 z2 N
End if * k6 o/ y6 y7 {7 c
End Function " Y' v+ g3 a; k3 p) b
% o6 C- f0 a9 |: x
'显示目录列表 $ G8 [+ ?5 @- P5 \
Public Function ShowFolderList(FolderSpec) 7 N* u9 K* ], n& {3 \8 o3 p# n
Dim f, f1, fc, s
3 l" o+ R6 r7 ^7 fIf ReportFolderStatus(FolderSpec) = 1 Then
+ M- c/ H4 y* L) K% \+ z% ?Set f = objFSO.GetFolder(FolderSpec) 0 Y0 {. F9 ~& E0 Z) a' n: f
Set fc = f.SubFolders
* M- O) x9 Y4 qFor Each f1 in fc : b4 |; O" A! z) e' R
s = s & f1.name . j" V$ I1 Q" Q9 X% J4 o
s = s & "|"
2 q( }5 Y; B, K: \Next * m6 _. o' `6 e: y3 i
ShowFolderList = s " C7 R1 C, I3 }; p! J, ^  E6 R# }
Else
9 B& ^# G6 E/ \7 |6 ~ShowFolderList = -1 0 }3 e1 O' s1 B
End if
2 z5 \9 G" j: x5 g: u% O! O/ x1 N+ UEnd Function ' C2 Z' M' N# m% U! {0 v6 Q
( I+ l* [! k+ C7 n
'目录复制
1 q/ p& D8 W5 y/ }/ Y8 I5 jPublic Function CopyAFolder(SourceFolder,DestinationFolder)
$ Q5 w  L, I% m0 x/ ?: IobjFSO.CopyFolder SourceFolder,DestinationFolder
7 K7 d& j/ k" r8 s! v8 vCopyAFolder = 1 $ L9 u$ T& n, P& _  R
CopyAFolder = -1 1 ^, x7 c6 k* d0 n' j' K
End Function ) }3 {; L& a) U1 N- r, T

% W3 z' t) a6 z" C! ?* ]3 F3 Z
: q* ^. |9 T$ B6 Y  `: U'目录进行移动
/ F- c/ @0 w+ P' o8 K/ ~2 vPublic Function MoveAFolder(SourcePath,DestinationPath) 0 @, B; b1 H8 T
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then 1 R7 w' X% k9 ~$ L& f6 b$ _+ H
objFSO.MoveFolder SourcePath, DestinationPath
2 f) n3 X/ W& \; [MoveAFolder = 1
$ b3 }3 K7 B2 X$ m8 `! K% K2 {2 ]Else
5 _& J  E% G+ x6 ]( Z( ^  h  nMoveAFolder = -1 % Y* N% x) [5 K2 H* N
End if
7 b. i7 [; I6 I) EEnd Function
! D( o; N! _. R8 {0 i. P
4 L4 T8 Y) g1 L  C1 T# }'判断目录是否存在 + a0 z2 _6 X. ?( q6 W& V: c
Public Function ReportFolderStatus(fldr) 1 W* `5 G; \7 r9 t
Dim msg 5 g+ j( Z4 k9 R" K/ t4 T
msg = -1
0 O  O7 F/ j/ Y, _- `" XIf (objFSO.FolderExists(fldr)) Then
' ^" E7 s* v, c  h% fmsg = 1
# I7 Y2 M: g5 j* xElse 0 _8 ~! c2 M0 P/ B) g) }: T9 L
msg = -1 1 U' l- V+ v; \: Y3 W
End If
; J3 k# l6 w# s' s% xReportFolderStatus = msg
  p, W" K; u9 k3 E# Q" tEnd Function ! l/ w# J0 ~8 X6 M4 o( I9 [) J
" U' ?7 `1 r! Q- a, n) e  g3 w
'目录创建时信息 1 H$ q) Q9 E+ W" \
Public Function ShowFolderAccessInfo(FolderName,InfoType)
* V3 \/ \9 }6 [6 s2 e' ]" E'//功能:显示目录创建时信息
$ O- z0 \, ?" M) o. L'//形参:目录名,信息类别
+ [% Y' F" J4 t# x+ `" V5 A5 T'// 1 -----创建时间 0 u4 S8 P# A5 @! W
'// 2 -----上次访问时间
3 M: h6 p; ~+ l; F5 L'// 3 -----上次修改时间 3 p) r2 P' Y! m# b% w9 y0 r5 R
'// 4 -----目录路径
5 ~, u9 Z  j$ @  w, W( _0 _8 m'// 5 -----目录名称 * Z* R. H# }; u: z0 F4 t2 e8 w
'// 6 -----目录类型
2 d& h8 W' J3 d- R' |'// 7 -----目录大小
4 i2 E4 v3 W/ |% z2 P'// 8 -----父目录
# t% H' F- a6 j/ }5 \& c& t'// 9 -----根目录 ' O5 ?3 y# G0 z- Y9 t2 ?2 E
Dim f, s
: E* `0 L/ ^. w7 t; XIf ReportFolderStatus(FolderName) = 1 then 9 s2 A) E# J  O7 d& A
Set f = objFSO.GetFolder(FolderName) * ]$ J8 K' U; @/ w& g( B2 |* U; g
select Case InfoType
- P0 l* f+ O( E8 {! p  TCase 1 s = f.Datecreated " c+ S: v/ A( o1 P
Case 2 s = f.DateLastAccessed . V, y$ F# y7 j. R) P1 H- V( x
Case 3 s = f.DateLastModified
* I& R" O! F% s7 B9 _/ {! R7 LCase 4 s = f.Path ' e: L* M4 X: L0 {+ g
Case 5 s = f.Name
4 |0 t1 P( u7 o: a8 v: e6 `Case 6 s = f.Type * @! U$ D" A+ w, p+ E" V+ }# o0 m
Case 7 s = f.Size 6 [0 P+ b" \$ W7 [3 E% B2 `+ S7 P1 x
Case 8 s = f.ParentFolder 8 i; Q; U' R( b3 Y4 p* s) V
Case 9 s = f.RootFolder , @3 ^0 T6 p+ f/ q+ E: o3 s2 j8 h
End select
# m8 }9 a8 ?- d; o# I, E+ {ShowFolderAccessInfo = s
% ^% I0 X+ C& ~0 ^! U1 C: sELse 2 t/ ]/ V  A  z! h1 t3 S6 t0 E
ShowFolderAccessInfo = -1 " r/ g+ |& A9 E  F
End if 2 I' C: j- ?: E' K, K
End Function - L+ c4 ]) s( }+ S8 u2 |: {$ Z
$ ?; @$ F* X% J2 _8 r
'遍历目录
' A9 f8 R0 u0 x' H: A5 jPublic Function DisplayLevelDepth(pathspec) * G( C, A+ d) z' [# _. q# x
Dim f, n ,Path : U4 g5 e% C6 m. A% }
Set f = objFSO.GetFolder(pathspec) 1 Y( I: Z  z1 c) m/ B
If f.IsRootFolder Then % T5 s; L# b) t6 T6 _( k
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder & H1 N( N9 S2 h0 p& R
Else
: ]3 W( m2 N$ R$ l' V0 h1 JDo Until f.IsRootFolder $ c& ]! u* W" }0 T
Path = Path & f.Name &"<br>" 5 m3 U5 N3 m) s% y1 K) t- P" u& F6 X
Set f = f.ParentFolder 9 y2 t$ b: {. `4 N, S( D- z/ j
n = n + 1
0 B) H  S! W8 _, g" CLoop
: i; R% @7 a  B9 Y3 S7 K/ lDisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path $ _# Q2 V6 a5 \* ^2 L4 K2 E; W
End If
9 m$ H3 G( w/ X1 o( FEnd Function
: Q7 \1 S8 g' W; u. M
& h3 C' T4 a( c& V: Z+ Q'========磁盘操作======== 5 w  }) M  Y4 o1 \' ?8 s3 H& Z
'驱动器是否存在? - k5 P- d( m$ ~3 P$ T4 i
Public Function ReportDriveStatus(drv)
) ~0 R* h, K/ s% ~Dim msg
1 D$ D. B/ q3 u3 B( E0 w5 a% Umsg = -1
5 f  G- \6 O6 {  Z% p- K* f* _If objFSO.DriveExists(drv) Then , Y) D% c2 i1 s9 z
msg = 1
) }3 e( _% b' h% y5 Z* N% cElse 5 y9 N8 F+ G$ p. v# E5 ~
msg = -1 2 G1 Y# J0 ?. O* g1 B7 z; E! @- }
End If
2 \  A. U7 Y* i. ]ReportDriveStatus = msg
" }) V( P* x$ Y4 `3 j& _End Function ; D1 N9 H% o2 m9 W. Z( t
$ T' f! y! o$ H9 o
'可用的返回类型包括 FAT、NTFS 和 CDFS。
0 ]: ?3 N- E: H4 n) r" N& v' KPublic Function ShowFileSystemType(drvspec)
! M3 I3 h7 B- R$ {Dim d
% A  G) {5 N% j5 _) o7 }If ReportDriveStatus(drvspec) = 1 Then
, h- ]  R) x/ b) u" M+ NSet d = objFSO.GetDrive(drvspec)   o7 a5 [) e! x
ShowFileSystemType = d.FileSystem ( D0 l6 U  f7 _, X; \
ELse * L- p& X( Y; H* ]
ShowFileSystemType = -1 $ I: D; L. Z; y  {. @, Q, M/ c
End if
2 `) N$ z4 i3 S' P1 kEnd Function
: H3 i. g2 o. M+ o9 v6 w# e3 o% TEnd Class
. \' t2 z4 N8 J9 a7 }%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

GMT+8, 2026-7-29 11:15 , Processed in 0.044403 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部