【高州情】高州人深圳站

标题: ASP文件操作大全 [打印本页]

作者: Longe    时间: 2011-8-17 12:38:09     标题: ASP文件操作大全

ASP文件操作大全+ e9 v: @4 U  t7 K
<% 9 W6 d7 v0 p/ M3 R, F
Class Cls_FSO & }' h  T/ w( S- C$ r3 I( q
Public objFSO
! h. O. z. F% o5 G" B, n) g& nPrivate Sub Class_Initialize()
7 P' a# X4 j# c- K6 d2 qSet objFSO = Server.CreateObject("Scripting.FileSystemObject") & J# `1 h- x+ B3 q+ h* B( k$ R
End Sub
) x$ s; b) ^* K( v  ?Private Sub class_terminate()
4 c; w' j# ^' T! b- y( i. H$ iSet objFSO = Nothing 0 S2 ~8 I' _$ G2 Y/ n
End Sub 8 H+ m, X# E+ M% }- i- g+ {

& M9 `3 H! u; o9 o- [$ h" E; U'=======文件操作======== # c& P6 x7 K" M# O
'取文件大小
$ y5 `% r  w2 x( iPublic Function GetFileSize(FileName)
, B- Y) c) _$ S$ UDim f 6 k+ c4 F" h  F/ G; }+ _8 g! e' k' }
If ReportFileStatus(FileName) = 1 Then
8 D# |. ^7 c7 t, p7 sSet f = objFSO.Getfile(FileName)
5 ~% ~7 e, V8 I3 OGetFileSize = f.Size 1 v8 p. j, s! e( ^$ k6 c/ T
Else ( Y$ R. L7 q. ?2 V9 ^8 s
GetFileSize = -1 ( j' W6 t3 w$ k6 W1 j# q& @
End if 9 Y* Q6 x: C, v1 o! A( ?8 H
End Function
0 p/ ]- p" E; A* {" \, n0 j3 X4 c- Q# m  {0 Y- P; C
'文件删除 8 G5 w7 E0 p& i& q6 v3 r
Public Function deleteAFile(FileSpec)
2 ^( Y0 l& U3 B# |# A7 ?If ReportFileStatus(FileSpec) = 1 Then
2 F8 ]- F* L5 q0 t: q. oobjFSO.deleteFile(FileSpec)
; d# o0 z3 Z( L! S5 z- b- pdeleteAFile = 1 : m4 |$ }, f/ ]) Y# s4 B7 w
Else
+ S" X9 Y; R- R) l, k) q  JdeleteAFile = -1 $ q$ R: O' b) |7 m# E4 ?/ ^3 B" r
End if + H2 N1 L/ n' g
End Function
+ K# P  F& b+ C' v! X/ N  ?" M2 c6 X; ~! w6 ~; p" r: Q3 o# N
'显示文件列表
" G9 E1 ]# X  @7 S4 {) jPublic Function ShowFileList(FolderSpec) : z$ |& C5 f  z9 Q) j  S
Dim f, f1, fc, s # _9 D) H. u1 e' S% O4 ^
If ReportFolderStatus(FolderSpec) = 1 Then : Q3 g) ~. Q3 G9 z* ^6 y: o
Set f = objFSO.GetFolder(FolderSpec)
- S4 U, _% c0 l8 ?( NSet fc = f.Files $ V# m5 u, \! l  k: x0 d5 X. h
For Each f1 in fc
9 b. S+ B' x! Y8 E7 @3 Z1 gs = s & f1.name ! `: y" l  l7 I% Y$ F' H
s = s & "|" # E0 I8 l3 V; Y1 o# o$ K* S
Next 4 K% i* n& S8 O( R6 h
ShowFileList = s
/ k1 m& C' k- G% B/ IElse : {9 {* t/ x$ v
ShowFileList = -1
7 M1 [+ f$ [$ IEnd if
: B& v. K7 O, T. f  g. S0 EEnd Function ) P* u3 d& u. `# O

. {0 L. r" T* y( L3 z0 ]3 f'文件复制
+ ^" I" k$ L# a! ePublic Function CopyAFile(SourceFile, DestinationFile) . x# M2 h0 }; L  z# }
Dim MyFile
' d% o  W2 r/ y( z  k7 [: |  WIf ReportFileStatus(SourceFile) = 1 Then 5 l8 N% a7 k- X
Set MyFile = objFSO.GetFile(SourceFile) 7 [3 M; u) _/ W/ y3 ^! b8 @% `
MyFile.Copy (DestinationFile) , q8 a) |! [1 U, f
CopyAFile = 1
9 @" e  }6 }) F! GElse
% L1 Z/ X6 R& x, CCopyAFile = -1 & _. {/ E, J# F+ _( ~) U
End if 7 x) r% B6 g) @$ h
End Function
4 v# A5 c# z6 T2 H. y! o# g6 K
4 H. k% p5 Y/ [$ v'文件移动 ( a4 b3 _1 @0 W! s
Public Function MoveAFile(SourceFile,DestinationFile)
+ z' t6 m( m/ n: {  q; wIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then / V8 R+ D# j7 U5 J  M0 f6 t
objFSO.MoveFile SourceFile,DestinationFileORPath # o' S' o$ ?$ Z& s1 N; f( }
MoveAFile = 1
' q# ]$ k$ r; Q3 a5 n# hElse , w7 X! _2 u/ h
MoveAFile = -1 / d- A8 m; b6 e, N: s
End if
/ M7 h% J) ^2 h4 n  t1 Y' bEnd Function 5 S# w% v- D$ `

0 p" J% `7 u$ H& _0 i1 `'文件是否存在? ( B( _4 `$ V) F. j
Public Function ReportFileStatus(FileName)   c0 `: f: c$ l% m( r. N, K( G
Dim msg 6 z2 h6 u7 [, K+ {! O! Z, h
msg = -1
9 B) q# e" g/ [- ?8 dIf (objFSO.FileExists(FileName)) Then ; j5 ?8 N( ?( d# F- r6 N
msg = 1
# ]2 ?+ h, B9 o) QElse
- }& g& \( D( t+ F0 ?  }- T" emsg = -1
" x/ @: P; p/ A* JEnd If 7 R7 \. f9 Z5 b; \; u& P' Z2 |7 R9 M
ReportFileStatus = msg 6 h4 u: b5 Z7 ~1 ]5 I9 R2 A7 h
End Function
) ^1 }% G* i9 h: Z1 A, d" t/ D- D& m5 e  q& `, ]
'文件创建日期
9 n4 h* {& s% y: U9 P1 O' W7 \Public Function ShowDatecreated(FileSpec)
- B# Y( g( G3 A) J& T4 x  XDim f
9 |/ s1 ~& e( ~! V+ j. s1 r% @If ReportFileStatus(FileSpec) = 1 Then 9 b+ @& F2 H8 e- E: P/ r) B# e
Set f = objFSO.GetFile(FileSpec)
# P4 v' D8 j6 }/ l6 a4 ]ShowDatecreated = f.Datecreated 1 V$ n  F# O7 ~. J5 D, H) ^
Else ' U4 H+ ?+ a6 ~1 G5 S# P# ~
ShowDatecreated = -1
. }' q: Z( x) I0 a+ `: m3 c/ e$ qEnd if
: C2 o- _: p+ y7 x# @3 I6 `End Function
, H4 M' j" o' l2 l3 W
% Q; X  `4 f; v'文件属性 / y& ]; i( L, p- F8 s
Public Function GetAttributes(FileName)
$ x1 P% F2 b2 ?Dim f
0 m7 u2 F" H0 j5 ]* z: }$ dDim strFileAttributes
/ Y1 L. [/ I6 \: [$ _7 w, ~2 s" EIf ReportFileStatus(FileName) = 1 Then
& v" d2 u; H/ S! d* E9 v) l* qSet f = objFSO.GetFile(FileName)
! j& S# w' v* o- c. l* n" sselect Case f.attributes . }9 U  e3 x9 T7 e* i3 P) b8 |$ H
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " 0 o- v0 p, [: ^0 E6 {+ [
Case 1 strFileAttributes = "只读文件。可读写。 " ; G" t9 s; ~6 O/ k5 F& \) {
Case 2 strFileAttributes = "隐藏文件。可读写。 "
. A3 |, }! O, C1 N9 k% b/ MCase 4 strFileAttributes = "系统文件。可读写。 " . B# h) \2 K5 L- ~3 i
Case 16 strFileAttributes = "文件夹或目录。只读。 " 7 Q6 v8 c1 m7 Y+ Y& h: O: b) ^5 E: g
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " . |4 R* L7 i2 _' x* j' _( S
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " 0 O3 H1 |" P% N6 F( C' X7 |- T
Case 2048 strFileAttributes = " 压缩文件。只读。"
2 {7 G9 S3 D; g: h. KEnd select
3 ?) w! d; K2 P! I+ GGetAttributes = strFileAttributes
! G. I2 z$ i9 ], ^( G0 ^! b/ Q% iElse 2 Y! w, t  }3 V* h; P7 l
GetAttributes = -1
: a6 C9 Y! F8 v% YEnd if % i9 @" f' Q. O! }
End Function
, X, ~7 ~7 U2 e* M" |; m4 v! x: @
'最后一次访问/最后一次修改时间
* G3 U: D# J) I, ?Public Function ShowFileAccessInfo(FileName,InfoType)
0 q# K* V% X, Z& H- S* T'//功能:显示文件创建时信息 % m( |+ n6 \0 |: x: e8 q
'//形参:文件名,信息类别 , L8 [6 M$ N6 y# H; ]4 y
'// 1 -----创建时间 - Z+ u3 n7 z4 y0 Z2 c3 W
'// 2 -----上次访问时间
6 U2 q6 {1 F2 q5 n'// 3 -----上次修改时间   |7 g/ F4 U) Y$ ^9 @6 }
'// 4 -----文件路径
2 e' _4 y6 z& s; Y/ g% f4 {'// 5 -----文件名称 8 n) q4 ?# ]: C- K" x
'// 6 -----文件类型
4 q) _9 \* U/ M'// 7 -----文件大小 . V) G9 ]5 Q8 e; }4 v* i
'// 8 -----父目录
8 L1 t! p2 c: P+ V9 \'// 9 -----根目录 6 u: E  K/ Y1 g. Y
Dim f, s % `! s+ }7 u5 e# L/ E- f; ]
If ReportFileStatus(FileName) = 1 then
1 z9 i' d5 m( {' ESet f = objFSO.GetFile(FileName)
9 t/ J( {7 i1 Zselect Case InfoType
  ?! x! p  |/ A9 z& j6 lCase 1 s = f.Datecreated / |: ]9 ~, Q  y) C0 S3 j9 r
Case 2 s = f.DateLastAccessed
7 f) `) d! i& J/ p! ~Case 3 s = f.DateLastModified ; C, r& A  V% g
Case 4 s = f.Path
& \: x1 |- j; TCase 5 s = f.Name ! o/ x; z& ^8 c- g+ P
Case 6 s = f.Type 0 X+ K' \5 i4 _5 M, J" l
Case 7 s = f.Size % G2 K6 B/ H' |- t0 ]: {- V* [- H
Case 8 s = f.ParentFolder 0 o3 A# M, O' t0 F: C) _
Case 9 s = f.RootFolder % K5 O7 O+ v( Q
End select
' p5 x9 x% L$ B- d' QShowFileAccessInfo = s ' G' V$ B: X& u% b  n
ELse - t5 S" _3 S; L3 [/ K: H* T
ShowFileAccessInfo = -1
- j8 P9 W2 z$ Y1 j+ h# kEnd if + R3 Y* u+ s3 K4 l
End Function ( H& y4 y0 Q: Q" a! K
3 o, H) Z0 i* j. q
'写文本文件
" N" s4 q9 P% h& H* |: dPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)   T& Z& o2 r; A. m/ p& E: [
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
" u  U3 |! i7 k# e8 hDim f, m
& H$ |5 K+ i  W% \- r! h6 ^select Case WriteORAppendType 4 i2 b, p8 e, J0 J8 x
Case 1: '文件进行写操作 : J% E3 y% V8 r' V. i, E
Set f = objFSO.OpenTextFile(FileName, ForWriting, True) 8 g- Z, }- J8 G* ^% w4 I* _
f.Write TextStr
# I6 _: D  H9 L1 ?+ D1 y, p/ Of.Close
& J: {9 X* Y) Z5 [( I9 l* PIf ReportFileStatus(FileName) = 1 then & W/ V+ b; n9 g3 \! f. b2 g$ B
WriteTxtFile = 1
$ E" a& }' T8 h  RElse
9 @$ o, Q# d3 b8 V/ FWriteTxtFile = -1
7 f. s2 n0 r2 g: G3 NEnd if 8 I. _4 W  L1 s( {
Case 2: '文件末尾进行写操作
7 K6 {. b* D3 G% }9 Z. n- `* Z0 c( U6 dIf ReportFileStatus(FileName) = 1 then ) q5 o2 N4 S( ?. T
Set f = objFSO.OpenTextFile(FileName, ForAppending) 7 E$ X" c* b/ h% j/ e% Q$ `6 A3 j& B
f.Write TextStr
: m# A2 ~* w5 ?3 T% _  g* B2 hf.Close / I( C$ ?* A! p0 T' i
WriteTxtFile = 1
; L1 {9 U( e  R( w9 t$ L' zElse
- P  Z0 E3 v5 X; l1 h) }WriteTxtFile = -1
, R( |' s% s- G5 S  k5 I* cEnd if 6 P! y, b; p% I& g8 f
End select + ~+ B$ S2 A: {* i; }3 `! x* T
End Function
, Y( N* f- B" Z! N, X8 o8 r. F
& S% m0 a) [& S% g, E'读文本文件 * A3 g$ Z# y6 l+ t" f5 B
Public Function ReadTxtFile(FileName) : e; g' F5 d7 J, V; Z: i
Const ForReading = 1, ForWriting = 2
( s3 k0 }  F3 l" K' P- l" Q. hDim f, m
. H+ F$ U; U! |If ReportFileStatus(FileName) = 1 then 4 F9 S1 r- T0 z( z0 A
Set f = objFSO.OpenTextFile(FileName, ForReading)
4 w2 ]6 f7 j8 f$ X6 s% E- m( B: J8 Bm = f.ReadLine
& ~* F' E5 V. E# y" W1 R& m0 a, nReadTxtFile = m
& [+ z) ~; i$ G" R1 T# ?f.Close
5 V$ u/ V" h# {* U5 A. b6 t5 f: kElse
0 z) U9 G. H+ u8 ~, p2 MReadTxtFile = -1
/ s# f% H; c3 eEnd if
* T4 U7 b7 G4 `End Function
! y3 \4 ~# [6 Z, S. G/ B0 L
: K/ Z0 Z; @% I- E% b'建立文本文件
, B/ h2 g  b7 r$ m! u
: v4 }& o2 j; f6 g, H& G. k3 P'=======目录操作======== 4 Z$ X7 v4 _  V8 y. }. |3 e* X( ]% [
'取目录大小
) d7 F0 B! ~, u4 ]/ `Public Function GetFolderSize(FolderName)
8 b/ ~( z0 @& ODim f
, M+ d! `) M- J: f) I2 XIf ReportFolderStatus(FolderName) = 1 Then $ l8 f7 j: D& c9 h7 [
Set f = objFSO.GetFolder(FolderName) - Y  j% x4 ~; M6 ^  O9 G& ]
GetFolderSize = f.Size $ _2 a+ {/ ?" s
Else
/ {5 v2 l( f) y  ZGetFolderSize = -1
! w! W) U! {7 ]End if
0 w' V- K: i& L7 w. K% X. f  WEnd Function
0 i/ p" _  B1 d$ t1 ?% z! V9 M$ l
+ s, b+ X- s. `6 K0 \* A# T'创建的文件夹   j0 W, j; D6 ?$ Q. R
Public Function createFolderDemo(FolderName)
4 G4 A2 s! I8 k* QDim f
! E0 ]2 b) Y2 v5 B, q8 vIf ReportFolderStatus(Folderspec) = 1 Then
+ f* A% M, n5 Z# ]; g' {2 M7 e2 ]createFolderDemo = -1
5 [3 z0 u; m! \# u1 LElse ! \; Z+ o- f# A8 q
Set f = objFSO.createFolder(FolderName)
, p6 T8 I; [" m; e0 KcreateFolderDemo = 1 1 R0 o- C$ C5 N4 |4 F
End if
) I" L# \! U- {End Function ! J$ W6 I6 i2 e( T4 e- }" l
. ?/ p( x' a, k! p& Y
'目录删除
) Q! L" n3 H9 o1 }, m& v- |& tPublic Function deleteAFolder(Folderspec)
; h* ^3 ]' ~$ Y+ HResponse.write Folderspec 0 V* ?$ ^- ~+ W7 n) _( F
If ReportFolderStatus(Folderspec) = 1 Then
1 p; t" r1 n' }5 YobjFSO.deleteFolder (Folderspec)
5 R9 x: h, q$ s7 {* a8 u1 Y# MdeleteAFolder = 1 & f+ Y/ F: N1 o# ^- a
Else
) j4 @# Z5 W& E$ A% u0 i8 jdeleteAFolder = -1
3 d# o4 J  c5 t/ P$ D, q+ F- |End if
3 P2 ~% F; o1 \: P* x/ vEnd Function * _8 }" n# [: c& U7 k

" J; C- f1 O6 O'显示目录列表
5 Q5 h5 y+ ?# ?& N- J; JPublic Function ShowFolderList(FolderSpec)
$ m2 f2 K/ c4 o% i, Y2 a; lDim f, f1, fc, s
% L+ H. T, z( UIf ReportFolderStatus(FolderSpec) = 1 Then 7 \) H  C  I8 }4 B/ p2 g
Set f = objFSO.GetFolder(FolderSpec)
5 r9 t2 c+ a/ K9 iSet fc = f.SubFolders 9 L5 J7 @. ^4 {6 W' {3 c
For Each f1 in fc
1 K. c5 u2 J9 x3 B/ T6 Y) h# v" Ws = s & f1.name % {( r7 _+ U. v
s = s & "|" 7 K* S* d$ V) Q6 v
Next
$ G! v+ Z( h; ^8 F1 A  ?# z, m  ?- tShowFolderList = s - V; K( R! H& J9 w/ L
Else
5 Q7 B2 W; I' M8 H8 }ShowFolderList = -1 % E" ]& V0 U) J
End if 2 T) t, b9 ?/ O" j* J
End Function ) X! t3 `" @" i" K) f
/ P! |* d0 {; C8 Z
'目录复制 ( h% I) Z% }2 Q2 e# q, |% N
Public Function CopyAFolder(SourceFolder,DestinationFolder) + J: n1 T" J  _
objFSO.CopyFolder SourceFolder,DestinationFolder
) z, u# G3 X# M  z+ ^+ g( R" LCopyAFolder = 1
6 r- L/ ]' U" }CopyAFolder = -1 3 S8 l% |) C2 z0 R$ u/ ]
End Function
  ?! b% s- x" Q3 p+ }# e0 ^+ |3 y/ i
0 N9 K# L$ f  k; l/ K0 h
'目录进行移动 * _& a& c, h5 x/ g4 g& E) ~
Public Function MoveAFolder(SourcePath,DestinationPath) & e  _9 l* Q  H$ ]9 |% M, l
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then 2 p( `% X% ^$ U( ^' C  L8 r
objFSO.MoveFolder SourcePath, DestinationPath 5 P, E+ I0 p( I, w
MoveAFolder = 1 , a0 \& ?2 {  f+ O2 y6 E* s4 M/ ^
Else 0 Z9 s3 ~' L; H6 Z( U, K
MoveAFolder = -1 1 m  _2 H0 q: y
End if ) p) N' C& r. R$ ?
End Function - E& F/ z$ _" i  ~
3 X; f' v+ \! ]/ ]9 J: Q: q* \) C
'判断目录是否存在 8 `$ a: _4 s* S. V6 R- I2 z& w! p8 \1 `
Public Function ReportFolderStatus(fldr)   d; P) M7 S- `/ [
Dim msg 4 [9 t* g. D9 w5 T  r, T
msg = -1 ) R+ q& d1 V( E* t! X9 l( K
If (objFSO.FolderExists(fldr)) Then # `$ w. }3 i5 G& u3 Q* f. j
msg = 1
8 [! t+ z4 W  w, Y7 V5 bElse
+ y8 T* m. b4 e* e6 @4 ?; J+ P0 h6 Smsg = -1 + k( {% [- ^; g% }$ f
End If * ~% d7 f2 M/ i9 d+ v: a# W8 {" Q
ReportFolderStatus = msg 8 w! h" V9 {; l$ Y0 v+ K
End Function 0 u/ j4 g- U2 z$ `3 q- Y. t

- S- D, \" h9 _3 @'目录创建时信息 - P( p! G* b7 P
Public Function ShowFolderAccessInfo(FolderName,InfoType)
( b) h: @2 V4 n" W  N/ f'//功能:显示目录创建时信息 : E; r# z& d, C7 k; w2 _9 H$ H
'//形参:目录名,信息类别 1 Z- e- ]* o  h0 J" G9 c( T
'// 1 -----创建时间 6 i4 s- g  z# I, u7 [2 \+ L9 o3 A& S
'// 2 -----上次访问时间
& }- e& l. i9 M! A  w'// 3 -----上次修改时间
; F; a2 j0 ]; E'// 4 -----目录路径
' K( N2 u9 d0 C; Z' E% f6 q) @'// 5 -----目录名称
$ D( d; x2 }; Q+ P'// 6 -----目录类型   ~0 K  l) [9 `1 F% s. B2 U
'// 7 -----目录大小
: Y$ K7 v. g  U+ F0 G'// 8 -----父目录
9 s* [) w4 z4 R" A'// 9 -----根目录
( p( F* s8 ?2 V9 }! ODim f, s
2 |* s  K; |! d8 S- s; X4 i; Y1 eIf ReportFolderStatus(FolderName) = 1 then
& D+ e; R# ?) r$ [- VSet f = objFSO.GetFolder(FolderName)
- ?) J" U; u3 V1 @9 yselect Case InfoType . ?2 L+ e+ f2 D3 Z! |% h  i0 E
Case 1 s = f.Datecreated . V. M$ f/ {+ ]" k8 n3 z& A
Case 2 s = f.DateLastAccessed
' _* h2 i9 P+ h/ F/ p" q" U3 Z3 ECase 3 s = f.DateLastModified * l( i+ H6 u0 n3 H2 i. ^
Case 4 s = f.Path , c- c  H( T( D& E: ^
Case 5 s = f.Name
6 H% A# p* y1 ~* X; N7 m, x8 x3 uCase 6 s = f.Type
" U- [- ?3 Y( t# K( N) FCase 7 s = f.Size 7 r0 F3 b7 E, @, q0 f6 P: J
Case 8 s = f.ParentFolder 4 k4 h2 }2 g# d9 m
Case 9 s = f.RootFolder 5 m6 Y8 P6 K; a7 n, E9 S
End select , h( d2 g+ V0 r( y0 f7 _- u
ShowFolderAccessInfo = s / u% E8 a* ?5 |' ~  V  ^# T9 B% e/ j0 W
ELse   r- N2 g4 F8 [
ShowFolderAccessInfo = -1 ' E, M- K  }2 V- n2 t; s" f- d
End if
; X* Y* M2 H5 w, m, _End Function
: c+ R% }# u# Z7 V; D  F( _3 R2 K3 Q" ^* a. j* M4 N) Z
'遍历目录
# f1 J$ v- W8 ?& G# }: D9 G3 V6 hPublic Function DisplayLevelDepth(pathspec)
! p$ Q- ~7 K& P& FDim f, n ,Path ' l5 A8 n9 P1 x8 z1 a+ z# E  E; @
Set f = objFSO.GetFolder(pathspec)   H& E% @. N4 `/ w0 o# E
If f.IsRootFolder Then
) z, D* W. ~0 ~DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
7 g# _' z1 J% _, k3 z* U3 k: |* o! _Else
5 B! u# j0 a+ f' sDo Until f.IsRootFolder , a) N6 L/ `. \, D
Path = Path & f.Name &"<br>"
" d' H* F6 N2 N+ j# nSet f = f.ParentFolder
& r  Q2 K1 e- m: On = n + 1
% I% }& u8 y! Q0 q- g' a/ s0 n5 RLoop - f1 I3 Z0 {) v
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path 1 J: b/ X( c! D) Y
End If
; M2 n. W+ x! T$ x% b: AEnd Function
5 A( I% Z* ^/ h' Q9 h, I+ K
$ R/ T  y; y! e, ~3 `'========磁盘操作======== # X) e8 U/ w2 k  N/ d" V% j, T
'驱动器是否存在?
+ w% f) S1 y* f- D4 N& C2 sPublic Function ReportDriveStatus(drv) & ^( b2 K. n+ j$ W! {2 K3 m
Dim msg / x# I$ ]* M. g8 o7 p4 c
msg = -1
$ ]9 T: a( C0 RIf objFSO.DriveExists(drv) Then ) B8 L$ N; a% Q2 J: p2 p! U
msg = 1 / z5 d  O' q) a- H8 u" w
Else / D, M% n/ R/ O6 e5 G
msg = -1
" K- ?& s' N3 B9 w$ iEnd If , ?6 f5 ~( Q; t4 j
ReportDriveStatus = msg
8 S, ]0 i' r, s  c/ I  EEnd Function
7 b9 O  @, E: I' C; }7 K& \+ R, H# ~! k
'可用的返回类型包括 FAT、NTFS 和 CDFS。
( ^" O; Z2 `( N/ |( APublic Function ShowFileSystemType(drvspec)
8 g6 F7 V8 x0 ^6 w+ p0 M, _Dim d
1 p5 ~" }  K4 }) s8 f8 j2 OIf ReportDriveStatus(drvspec) = 1 Then + W& @$ B. `, I' V/ H* j
Set d = objFSO.GetDrive(drvspec) 8 ]% |* B0 K, {! B( T  K- c
ShowFileSystemType = d.FileSystem
8 r: ?" D# h  x( t* b/ s% g2 AELse % g* i5 ?  [  n9 z8 D, q9 E$ f4 J6 }4 c
ShowFileSystemType = -1
+ E9 W5 n* G1 Y$ SEnd if ! n2 o- u6 G" L1 ^
End Function 2 O$ k$ d9 L7 l3 Y) d& n# b! Z" G
End Class
6 x  x, w. n, J9 X) k%>




欢迎光临 【高州情】高州人深圳站 (https://0668qq.cn/) Powered by Discuz! X2