【高州情】高州人深圳站
标题:
ASP文件操作大全
[打印本页]
作者:
Longe
时间:
2011-8-17 12:38:09
标题:
ASP文件操作大全
ASP文件操作大全
: [) V5 C0 z% j$ [: a* \
<%
. E4 R: d" d9 H s) u i. e d' R
Class Cls_FSO
$ [6 N& j) p) e$ \& g, ^' l
Public objFSO
! T$ |( {! r8 {& V
Private Sub Class_Initialize()
2 I. ^2 v/ Z. e2 R5 d0 s' Q
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
q7 E8 m- Q3 x; }
End Sub
% m$ M# Q( h* \5 p
Private Sub class_terminate()
( z" F$ G3 _9 O+ z Q
Set objFSO = Nothing
4 i1 p7 R9 T% a: w# ]" Q
End Sub
' {& f# p3 W# C. \0 B
' o9 L( o* ] ]
'=======文件操作========
1 h$ X; d( M/ B* P# R" x
'取文件大小
" J! v* i; E+ r- O6 {5 [
Public Function GetFileSize(FileName)
" ?9 Q4 m+ a) }' a5 T7 A
Dim f
9 S$ C; T4 u! D# o. y: p+ y! P7 m
If ReportFileStatus(FileName) = 1 Then
( g5 c& x5 R- y1 P; j# a
Set f = objFSO.Getfile(FileName)
" i2 {0 |* @+ n. o' V0 N
GetFileSize = f.Size
2 b( T% L3 W1 H* h% w
Else
; _: [& i$ z/ D, P9 {& r6 w
GetFileSize = -1
- K. ^9 K C5 j6 g, o
End if
: X/ t0 e0 T9 Y8 o" N J
End Function
$ r. |4 M+ K% y) @2 S$ i7 F
4 [4 O: n+ m: J; h2 f$ H* C
'文件删除
( f1 n' Z; Y: A
Public Function deleteAFile(FileSpec)
3 Z. q' i1 j. t1 z
If ReportFileStatus(FileSpec) = 1 Then
% V1 X2 Z! Z/ }0 X Y
objFSO.deleteFile(FileSpec)
1 n( G4 N+ P: Q' L* V& j
deleteAFile = 1
, b' j% t/ C) @- I
Else
; C$ V4 n k3 H: _& t
deleteAFile = -1
* U' T7 ~5 q) t& K
End if
% h+ V0 q% i, N" `. V
End Function
; ^" w% d& t7 @; ]: M
" i* K6 O d$ `
'显示文件列表
4 n5 n' S8 a; Y$ i6 o' C+ J% S
Public Function ShowFileList(FolderSpec)
/ o, u& _$ m; A/ q
Dim f, f1, fc, s
" h m2 x" F: ~+ m9 d! y5 ~, o
If ReportFolderStatus(FolderSpec) = 1 Then
. o& G0 [2 m3 ]6 Q) n$ l% k
Set f = objFSO.GetFolder(FolderSpec)
1 Z1 X1 r' T" v: ~% Z
Set fc = f.Files
+ ^0 ]* W7 z! \5 i/ `
For Each f1 in fc
4 S0 ~8 H$ u; l: F7 k
s = s & f1.name
2 d) T0 X( m# z+ Z% e* R
s = s & "|"
! H) a( r5 k" L( X
Next
3 m: f: _! M+ i3 c8 c0 t4 i1 F
ShowFileList = s
& c. i9 `7 n. T" U
Else
; |5 P/ s m* L0 [+ B0 c
ShowFileList = -1
2 ^: V, k, q- w
End if
* Z; @. X: q. m' N) Y" M; C2 S
End Function
' E2 h2 Y, [3 w: x" K) X3 X) v/ i
+ b' P0 Y6 i" k) H/ j; p4 m
'文件复制
! h, c/ T7 o5 `
Public Function CopyAFile(SourceFile, DestinationFile)
2 A' s) t# Q: N
Dim MyFile
" B$ Z% D- v# j* Z0 D% b- [0 S2 O
If ReportFileStatus(SourceFile) = 1 Then
2 O) K7 E! x& c% A$ y+ v/ f( e- C
Set MyFile = objFSO.GetFile(SourceFile)
5 P8 ^* C( C6 C8 }2 b% G. K
MyFile.Copy (DestinationFile)
& y0 Q8 x. i- }
CopyAFile = 1
( m4 `$ A3 I* I( B* F [6 O+ i2 @
Else
- M" h! c# E) U, t9 H0 O
CopyAFile = -1
8 L& ]; B+ x( g
End if
. \) A7 @3 F# d
End Function
; P$ ^$ C" _, q, _+ l& }4 X0 \
1 p# [ K' A/ `. I* B! q2 P, Y2 f
'文件移动
& \1 R! `! q$ f! C
Public Function MoveAFile(SourceFile,DestinationFile)
2 D5 e9 B, r- R
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
4 N. B5 Q' e; s* L- _. V6 v
objFSO.MoveFile SourceFile,DestinationFileORPath
: l% K& f" L% Q; n) M2 |
MoveAFile = 1
0 Y! w5 c( m n' e
Else
- ~- e9 o6 l1 q$ \% }
MoveAFile = -1
; Z% b) U# }' z
End if
/ F1 s. M; A8 i" Z
End Function
' @3 H9 N7 U% p' f3 K
6 g4 Q6 Q, N# U! J2 W5 H# ]9 {
'文件是否存在?
! H; N9 r( }( _0 j, @& O/ } I6 U0 V* J
Public Function ReportFileStatus(FileName)
. \3 Z) z& Z9 y1 r6 ]+ y
Dim msg
" U% A1 o/ @; H/ k: a; s
msg = -1
5 @, B9 E F+ F8 c" \6 K7 g& M; c
If (objFSO.FileExists(FileName)) Then
8 ^) p" g! M& { [. Z: r
msg = 1
+ J6 U# X/ p( n. ]8 H+ b
Else
/ s3 d& P9 c/ [, {, j5 \8 \
msg = -1
9 m, o4 k+ S' s- X- ?! l
End If
: S7 }4 A3 d- B7 K0 t) j ~
ReportFileStatus = msg
$ y! z Y; Y; F
End Function
/ t! B0 z* l I/ o
# M3 r! ~2 J" c
'文件创建日期
$ L! p0 \. E0 u% }: W3 G' l( T
Public Function ShowDatecreated(FileSpec)
! ^, Q H$ \/ s8 ]0 d0 r
Dim f
6 U a( {; H. `# S- n( c! ]
If ReportFileStatus(FileSpec) = 1 Then
1 c! X Q1 q2 q2 ~# w- ?# G
Set f = objFSO.GetFile(FileSpec)
2 r: P5 F1 y& d' Y. E/ s
ShowDatecreated = f.Datecreated
3 F; ~6 w5 e. ~% K- k( I
Else
7 W* E2 O$ X3 z/ b a
ShowDatecreated = -1
' e) s0 K6 v6 ]. c( m ^( r& M
End if
0 B& |( K, ^# l4 G% h& o2 \
End Function
! T* C4 H- f6 \/ o, G, w
: B: s- }; X0 H4 ]
'文件属性
# d3 K7 C: v3 ~- F. [
Public Function GetAttributes(FileName)
$ C* `7 w9 V }4 G5 }* p4 a
Dim f
% K6 {/ E* M' V& ` Y. I
Dim strFileAttributes
) D' G, Z2 t9 z1 }5 I l
If ReportFileStatus(FileName) = 1 Then
6 U U( G3 Y% K' S9 K1 J+ j: F
Set f = objFSO.GetFile(FileName)
# O( O, C5 E. S' L3 U
select Case f.attributes
4 U# e& N3 J2 ]2 I; Z
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 "
" z5 J4 Q* J4 _) [+ u- ^
Case 1 strFileAttributes = "只读文件。可读写。 "
" T& |0 |$ p1 }2 \. d
Case 2 strFileAttributes = "隐藏文件。可读写。 "
4 j2 i) ^6 q8 x b
Case 4 strFileAttributes = "系统文件。可读写。 "
# ^( g) _2 h+ ~6 g- K
Case 16 strFileAttributes = "文件夹或目录。只读。 "
( {4 y) F+ L$ j9 u8 [* ?0 K
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
* i! O# a2 b) B" O
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
8 B$ ]! Y( h2 d' W" E* Y) O
Case 2048 strFileAttributes = " 压缩文件。只读。"
8 K! V5 _4 t2 w% l3 p
End select
5 Q. ~. d; Y; b9 c7 J0 Z$ s! F
GetAttributes = strFileAttributes
7 s2 z* V5 z5 e- u% u. x
Else
4 f) V% k" L8 Q6 F, {: C
GetAttributes = -1
; ]0 g# m1 l1 k1 E3 {
End if
% [. T- r" U/ |& H8 Y
End Function
! a u4 U# y' x# u9 p. Z6 E
) h+ J- o% m+ U' I5 _" S7 |" h5 B
'最后一次访问/最后一次修改时间
4 ~5 i. x- }- h
Public Function ShowFileAccessInfo(FileName,InfoType)
# W$ R, p4 ~1 `/ n
'//功能:显示文件创建时信息
" C% `6 A6 J+ A( L; B6 j
'//形参:文件名,信息类别
9 @2 |9 N# m7 A+ s: r
'// 1 -----创建时间
2 ~4 @7 G# ]) r9 @
'// 2 -----上次访问时间
7 C3 A+ y+ {* v9 u, {
'// 3 -----上次修改时间
4 c, ?% |* D7 w1 L/ M# E$ B! z8 M
'// 4 -----文件路径
- h: m% f9 d* C
'// 5 -----文件名称
6 R: h! o) U! g- C6 H
'// 6 -----文件类型
! p6 q" [$ F; m
'// 7 -----文件大小
# X l1 @! D, |) c
'// 8 -----父目录
5 w' w+ `4 r2 K$ [" e2 D3 g
'// 9 -----根目录
' T% f2 [8 \& {7 z& k/ _7 k& o4 H
Dim f, s
# O5 S1 T( O& d0 x, t: O
If ReportFileStatus(FileName) = 1 then
6 ~* `- ]& V* |
Set f = objFSO.GetFile(FileName)
$ a) T# p+ @- ~; J2 ] h' v9 L
select Case InfoType
: W/ D0 b) q0 [' |' h* [+ p: @
Case 1 s = f.Datecreated
& N: J- `" k* p" h4 U* y
Case 2 s = f.DateLastAccessed
: n' L3 h+ g4 L9 R' M
Case 3 s = f.DateLastModified
+ v8 X. ^+ g8 {6 U, x6 @# R$ k
Case 4 s = f.Path
5 o# p3 w, O! i) f" F1 X, P- X
Case 5 s = f.Name
0 P% V; p: w: ^' Y- \ l
Case 6 s = f.Type
# A T# H& A; _6 M
Case 7 s = f.Size
5 u7 w0 H" u0 j0 h7 l" s
Case 8 s = f.ParentFolder
" f$ ?9 Y- w; N; v( B+ _1 J* u! H
Case 9 s = f.RootFolder
) [ V5 E! |) C
End select
. F! b! d6 M C. X6 T
ShowFileAccessInfo = s
7 b8 L( H; q: ?4 Z
ELse
b: E) H, Q% o" `" i- h0 F7 z
ShowFileAccessInfo = -1
$ l8 Q( I, q$ F$ N6 N
End if
. N3 g9 {& Y, s3 r' P# w$ u
End Function
6 Y$ U O1 `$ I" K# K
& I, t; a: h6 h6 j9 t
'写文本文件
+ T4 d/ O# L& t9 C' z- `% Y
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
5 {: U0 Q6 F: m# { I
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
& [* u: ^- r7 T8 {
Dim f, m
( G( p0 Q5 D7 ]& K: Y
select Case WriteORAppendType
7 ?8 L# o& r7 Q+ P/ }5 T
Case 1: '文件进行写操作
4 f, g7 Y* H& B& j9 x
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
9 f- O! Y9 y3 q& S. X7 D
f.Write TextStr
9 x, P% S2 q2 x/ w
f.Close
8 D* ~* l& m: L8 t1 g3 r$ {
If ReportFileStatus(FileName) = 1 then
/ X' v5 T7 I( U6 `
WriteTxtFile = 1
: Z9 l" ?" J m- |. ]( f
Else
- a( H5 Q4 ]5 |' H) l( x% H
WriteTxtFile = -1
, w7 D1 d0 X. r5 N8 L
End if
$ \# u* \% Y8 v+ a9 |
Case 2: '文件末尾进行写操作
$ o) W: F+ T/ {" a5 Q5 Q, V* L5 a
If ReportFileStatus(FileName) = 1 then
$ k; T* f: Y% O4 B6 y0 ^0 m
Set f = objFSO.OpenTextFile(FileName, ForAppending)
0 [; M* _) ~! C' d
f.Write TextStr
9 h8 |$ x! |5 K; N# }3 }
f.Close
# c" I; Q, w) V0 n! |% F7 P
WriteTxtFile = 1
6 X# K' v7 O) Z5 J
Else
0 x1 w) Y1 U9 k) @1 Y: r9 A
WriteTxtFile = -1
7 n2 U! z6 v0 p8 P; y
End if
6 a' C: T8 U2 I( _; a1 S! q
End select
" ?+ M) u7 Z! O; ~9 E
End Function
! z, i. i6 ?8 o: S5 Z
* g" o& @- [# k8 K5 @3 _
'读文本文件
! J5 x j" n7 ], N) G
Public Function ReadTxtFile(FileName)
T& S) k$ i3 d4 Z7 W; \
Const ForReading = 1, ForWriting = 2
_# h1 @2 b( y, |4 b5 o( z. a: Z
Dim f, m
& n. N. j( }, z2 ?/ E q
If ReportFileStatus(FileName) = 1 then
8 Q4 l5 l7 P2 y4 w$ q
Set f = objFSO.OpenTextFile(FileName, ForReading)
4 L) n# A& s7 x1 Q" _% e5 X- r5 D# j
m = f.ReadLine
, Y6 \& n8 M. k6 \6 k( v1 H# Z3 I" F
ReadTxtFile = m
: J0 ~8 J' G: k+ C
f.Close
; @) Y! P8 K; _+ H& s
Else
! z' k& b# F, w
ReadTxtFile = -1
2 X& d1 N" ^3 |- r
End if
! J4 A: a: L; D' j8 w- _4 t# H
End Function
/ ~- x# e1 c* A$ c
0 _# r: @7 I w4 [8 n @# u0 Z% {
'建立文本文件
5 [3 q, A+ F2 Z" A9 j3 o4 f0 B7 U
7 X% I/ p+ g! Q$ n& _
'=======目录操作========
9 Y5 e- B. s' ]) N7 _
'取目录大小
4 R- t J; t$ V) R9 z0 c! u
Public Function GetFolderSize(FolderName)
/ ?2 | q: q. v! r9 u1 x j6 J
Dim f
" a0 w7 O7 X* V! C
If ReportFolderStatus(FolderName) = 1 Then
* B8 c" j# {8 G4 C1 v2 X3 x
Set f = objFSO.GetFolder(FolderName)
% v8 L$ e4 ]9 g" I
GetFolderSize = f.Size
1 ~3 G7 m2 y8 R( `/ Z' P% F4 d
Else
/ s5 a( o% M, X% z- w+ x
GetFolderSize = -1
' ?; L3 P! T4 o7 p
End if
+ H9 G7 S+ o2 A; ^( P n
End Function
4 Z1 k) A# v2 o5 z! q
+ j: s, } e: a+ X, h9 ~
'创建的文件夹
2 ~8 y. ]: [$ {* X" c" H
Public Function createFolderDemo(FolderName)
. u) i' y2 R8 A
Dim f
0 u) y( w7 t& C: b5 m$ |. l' b! U% P
If ReportFolderStatus(Folderspec) = 1 Then
- \/ K O3 u5 h3 G5 A9 E
createFolderDemo = -1
% }* n: e2 m' a. |
Else
: ` x+ H% S, h& z! v. W$ V
Set f = objFSO.createFolder(FolderName)
! T. V& `. Z& b Z6 J2 D5 l
createFolderDemo = 1
! m; {2 G6 {4 l7 Q
End if
% Y; A9 J5 { p. T/ {; Y
End Function
^6 I4 v% j6 R" n
: v( L& H$ F( f0 M
'目录删除
' e% [/ U. T% K. |& |: \ Z
Public Function deleteAFolder(Folderspec)
1 b0 N8 x- f4 c5 ?
Response.write Folderspec
6 r9 v# e& l) n- H3 H4 N4 O* y' w) u, m
If ReportFolderStatus(Folderspec) = 1 Then
( _1 a/ Q# f. s+ I+ _2 O. O
objFSO.deleteFolder (Folderspec)
2 ~, |, J3 b7 C& T9 M/ ]9 c
deleteAFolder = 1
/ l Z5 f% E5 v( B) ^: Y0 r# M. s
Else
/ p0 W6 s, H8 H# f! S
deleteAFolder = -1
) {. F! b6 S: g+ @7 n
End if
- G7 N5 b# O% o g# A( }, y" K
End Function
% M* w a5 d5 \& d7 C
! V9 X3 R2 k$ [: l( R
'显示目录列表
3 C4 i5 J# |! t7 X
Public Function ShowFolderList(FolderSpec)
7 V$ r) L p% u+ o
Dim f, f1, fc, s
; _0 h1 l- C5 c' D2 N
If ReportFolderStatus(FolderSpec) = 1 Then
W$ N' P9 ~- S# D$ N6 @8 [1 ? v
Set f = objFSO.GetFolder(FolderSpec)
f* L: O) n6 s& h
Set fc = f.SubFolders
- F& z: }8 C5 Z" E7 G* e R1 b6 L
For Each f1 in fc
- B# D! ` c: }+ o/ L9 N
s = s & f1.name
3 i- s! v# t* _
s = s & "|"
3 e8 P7 ?3 @; _- W9 @; u; X; Q2 f
Next
8 C' I7 @" J _2 i+ Y7 q0 [. x$ f# ]
ShowFolderList = s
( b- I& Z% Z- Z
Else
7 x) v1 O/ i4 ~9 x* R
ShowFolderList = -1
/ y& Q9 C5 _; c9 M: A
End if
8 O7 O& t! Q' V
End Function
/ _$ h* i. b2 X0 c3 s
( J* w6 ]4 ]1 K# w4 o# m' R
'目录复制
. d* x+ W( C* q
Public Function CopyAFolder(SourceFolder,DestinationFolder)
7 |# f# Z3 L- p8 T
objFSO.CopyFolder SourceFolder,DestinationFolder
4 q- d* d2 G, P
CopyAFolder = 1
: C& N: s! K" K @& r5 u. F
CopyAFolder = -1
) V+ P+ Q( t, M$ m
End Function
$ @5 B1 L' k7 Y1 P m7 O' {, S
3 q% a: V- r2 w: _9 f
( \6 H% x) F/ Q7 ~
'目录进行移动
* _: l3 M! v# g" n
Public Function MoveAFolder(SourcePath,DestinationPath)
8 Z1 E' ]) O2 g6 B! X2 v# J9 p# D5 G
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
9 Q/ D1 w# O4 v; C, c( Z
objFSO.MoveFolder SourcePath, DestinationPath
8 E4 H) D$ {3 S' s
MoveAFolder = 1
( b+ \: t8 q* {% |
Else
4 A6 m3 B/ t( j: v# d: B% |6 n
MoveAFolder = -1
) w& { V) h3 I2 U" u' H
End if
$ D# G9 T3 ~3 E8 K" W4 L2 o
End Function
j$ \' J! m& ?9 O5 c1 x
5 Z, o. C* y& [
'判断目录是否存在
0 c3 R+ L3 Q# ]8 ?& Y6 X( d# a' L
Public Function ReportFolderStatus(fldr)
5 v9 F$ n/ u6 |; W7 h) g& Q4 z
Dim msg
: f Y: W/ I, T# H! @# y
msg = -1
9 Q% Y+ `+ D% F6 Q& f h3 E% I
If (objFSO.FolderExists(fldr)) Then
5 Q; g& I, g- V2 C, s
msg = 1
, h- S x: n/ P
Else
$ X" W- G7 a" A4 D
msg = -1
, G0 s g, ]0 O; K7 G/ I
End If
* F! J/ S# V0 Z' {9 O
ReportFolderStatus = msg
: q; Z. J# L2 Z* q: S0 z7 R
End Function
, j j5 _' w+ ?5 A- t: [ t% F
2 [0 t+ K$ O, Z+ A, c+ {
'目录创建时信息
! J) k' f$ x. b* J2 A
Public Function ShowFolderAccessInfo(FolderName,InfoType)
! \" o7 W6 [; W8 x- d& r
'//功能:显示目录创建时信息
+ E+ Q, p' w0 L
'//形参:目录名,信息类别
* S, |( E4 d) D! \6 v* C1 d$ r5 l
'// 1 -----创建时间
* ~* c' Y' t u3 h% E6 Z5 q! L. B% r
'// 2 -----上次访问时间
$ T) J. G3 ~" R) K
'// 3 -----上次修改时间
8 g( o* k, o) I- X- v" r9 ?
'// 4 -----目录路径
& \; G1 {& Q4 x6 \
'// 5 -----目录名称
! z, ~! A( z. J2 j3 y" D# o& o; [
'// 6 -----目录类型
& x8 x5 }. g5 E" L$ v8 r
'// 7 -----目录大小
9 O8 t# g2 E- B. n2 ^" c, G
'// 8 -----父目录
2 P' E) I: ~1 Z' @6 N" o
'// 9 -----根目录
7 A( ]$ H9 b6 [0 j ]0 A- l) P+ @
Dim f, s
6 g1 O% ], p! v0 h' R3 ^( i. H# K" p
If ReportFolderStatus(FolderName) = 1 then
3 S8 R# g: B; B+ a0 O, v
Set f = objFSO.GetFolder(FolderName)
+ E T! x# p4 d6 \8 T6 l# F d3 X
select Case InfoType
- ^1 E: U+ \6 m6 v9 T
Case 1 s = f.Datecreated
! l, v9 W, g) ~% A2 L* K- f( S+ \
Case 2 s = f.DateLastAccessed
% G- o, ?7 A- S" f2 a, a4 {8 |
Case 3 s = f.DateLastModified
4 W2 Q* s9 g% S' Z6 r
Case 4 s = f.Path
) O7 z% h% Y' T, _0 I: {# d
Case 5 s = f.Name
1 {9 t6 ]9 X/ c7 ~& l
Case 6 s = f.Type
$ }' r: P7 U" q( z4 Q' B
Case 7 s = f.Size
, I% F! y# ]+ U8 O+ ]$ U0 M% O
Case 8 s = f.ParentFolder
, N: A8 X; n. Z( m) m# ?
Case 9 s = f.RootFolder
4 a* U7 l5 f$ f4 \" K3 Z
End select
. D! E2 n; Z! M" S1 ?5 o
ShowFolderAccessInfo = s
4 @( v+ ~& _+ l- K0 k- ^
ELse
2 a# J+ f% [% |( b
ShowFolderAccessInfo = -1
" B9 [4 v. O, p% ~. @8 w. o
End if
9 a) E$ R% V; M9 q4 U
End Function
: T8 B. ^/ u: J1 k
) e3 C; x+ l9 i% |& [6 }
'遍历目录
* D" b' E X& I3 g, L
Public Function DisplayLevelDepth(pathspec)
7 o. O2 G) W7 N2 {* K4 A* m
Dim f, n ,Path
1 `4 j# h. i- M. `' c# j5 W
Set f = objFSO.GetFolder(pathspec)
1 V. T6 X- ]* D
If f.IsRootFolder Then
! K% L7 o; T' N) y8 m
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
+ G/ H ^! ]$ g/ T8 V( E( M: w
Else
, M7 M3 ]! l6 e
Do Until f.IsRootFolder
1 }9 v% N; C& `; O! Q) n
Path = Path & f.Name &"<br>"
4 z- W# ~# v2 J' Z; N( K
Set f = f.ParentFolder
4 M% ]/ A: E2 _/ @/ l5 X4 L
n = n + 1
' z* x% ?0 Y! S7 y- c. k' _
Loop
, a& S$ e" V' _0 n
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
) L5 H9 ^9 s B& i: x' ?/ T
End If
# K2 n7 I+ u; w4 M9 B1 X
End Function
8 Q |0 C ?5 h; j
3 T1 ^7 b0 @- \8 _/ |
'========磁盘操作========
4 S: s5 A3 k- I3 I; G
'驱动器是否存在?
9 ^* J9 |$ R+ r0 I9 z+ W( Y
Public Function ReportDriveStatus(drv)
- `3 n/ X* e1 \) K! U
Dim msg
0 o" x1 ] S; S; U1 o6 v& U
msg = -1
9 P, J& _- S9 r+ W& |3 a
If objFSO.DriveExists(drv) Then
3 W' i4 r9 M) o1 N8 z# }
msg = 1
1 w [+ o; B4 j& o, _7 N
Else
+ @1 R. M$ @2 e6 i* Q, J' v Q
msg = -1
" ?/ D* }( m. z' I8 ^( |) W
End If
7 l0 T# u+ q# @% R- Z, b* \
ReportDriveStatus = msg
4 n- G( y! j& H; Z
End Function
3 `8 _" z/ p9 h: O \
( u+ e4 c6 v, _
'可用的返回类型包括 FAT、NTFS 和 CDFS。
2 R' \+ A2 l+ f! k# V3 F5 O
Public Function ShowFileSystemType(drvspec)
# f/ G9 r0 D2 X6 k
Dim d
9 x$ y* I* n7 ]" w$ O
If ReportDriveStatus(drvspec) = 1 Then
/ k" k, Y! b2 x( u T
Set d = objFSO.GetDrive(drvspec)
$ J* |3 `0 G: ]" w {8 z7 _# W! f
ShowFileSystemType = d.FileSystem
/ S; y+ b* b0 a1 |# `
ELse
% {) R: h9 g# m g4 s8 a* {
ShowFileSystemType = -1
9 K7 K M& }: N) t! C, K6 X: G. _
End if
5 C' C# d) |3 b( D6 j1 G+ Z
End Function
8 Y' n$ N) Q, ~& q! e
End Class
3 w8 s: i6 O! n7 j: f5 P
%>
欢迎光临 【高州情】高州人深圳站 (https://0668qq.cn/)
Powered by Discuz! X2