【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

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

论坛元老 网络高手

跳转到指定楼层
1
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全) M3 O) h" `  g4 U$ f
<% ' l0 a4 Q* Y/ Q) ?; c
Class Cls_FSO 5 v# ?# C: F- S, |( B. X. A# V
Public objFSO
& z# v  O2 w" ]7 U- x: bPrivate Sub Class_Initialize() / k9 I( E  I* u2 Y
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") * J7 W/ z3 k; e$ {# L
End Sub 7 P4 @' C) o- w: j
Private Sub class_terminate()
0 n# y4 g0 S9 V$ v# L: QSet objFSO = Nothing . W  f/ Y3 Y* i3 p  i( `
End Sub
6 I$ V* X. _# g- n8 m8 {
" ^/ s0 @% l. S& D8 d6 ~'=======文件操作========
; i( n+ _$ _4 I'取文件大小
* o' s5 \% K/ Z% y8 nPublic Function GetFileSize(FileName) 8 D: D; H1 p7 w+ V6 A( I4 Q
Dim f
: Z! P, s. }. W' ]If ReportFileStatus(FileName) = 1 Then
6 |( b* U- g% e! A) v5 T" tSet f = objFSO.Getfile(FileName) ' l7 ]1 Y  F/ I7 H$ ^" |% Q: b
GetFileSize = f.Size & @7 o3 Z0 X" L* g  u
Else
; M6 J$ j0 G  U, t& i- [& d$ Z: o! ]GetFileSize = -1 ' M0 A1 y. g, j+ F8 c4 \& R
End if
% f' o/ S) A/ |7 WEnd Function
# x7 V  D6 D# S: Q/ h+ g0 Y
" [$ N. ?  A+ M& I9 X7 q'文件删除
/ z- ]7 P9 g. z8 J; s: OPublic Function deleteAFile(FileSpec) ; U% F8 j" C- a/ w+ a
If ReportFileStatus(FileSpec) = 1 Then
$ p+ j/ v8 s$ R7 ~+ JobjFSO.deleteFile(FileSpec)
$ `7 E2 p! T/ ?1 wdeleteAFile = 1
8 L; q! C! x! s4 c# a6 @3 jElse
5 N. w" @4 h+ g1 zdeleteAFile = -1 3 v; q, I+ t  e* R; o* ]
End if + R/ L8 Y3 w& ]
End Function
% C! ~! ?/ I/ I5 Y- E+ W- u! y/ g0 m$ y6 U
'显示文件列表
4 ~3 a' U" \; S$ YPublic Function ShowFileList(FolderSpec) : e" c  ?: B) C
Dim f, f1, fc, s ! K' w5 ~, r% V$ j
If ReportFolderStatus(FolderSpec) = 1 Then ! K8 u  f0 S: O
Set f = objFSO.GetFolder(FolderSpec)
' }# }9 s; o* w; t! i9 BSet fc = f.Files 3 Z) \8 |* B' S% e1 Y7 u  ^
For Each f1 in fc 7 B, z3 y# m8 K9 @
s = s & f1.name
# F) @4 S4 w. ps = s & "|"
0 p; G5 f1 E1 I1 ]& FNext
8 h! W8 `! `6 U$ MShowFileList = s
4 W$ \' j  K8 v& r% c9 v  SElse - C% \) Y+ `% b$ `8 T3 D( L
ShowFileList = -1 6 [/ z3 A$ y2 M6 j5 b
End if 6 A4 D# S7 v4 j; k
End Function
8 X" d( D% L0 S& ^9 Z
7 }* D, V7 I  u  B, C* p/ W'文件复制 + ~' h9 p5 S0 q8 {+ R2 t; c
Public Function CopyAFile(SourceFile, DestinationFile)
! c4 y: F' [. q3 r% w9 s$ YDim MyFile : L' k' {$ W& J" P+ L  H
If ReportFileStatus(SourceFile) = 1 Then 5 p3 y4 C* I0 A% @, }! Z) e9 F
Set MyFile = objFSO.GetFile(SourceFile) 4 q, O9 I3 i; j/ F, H& _
MyFile.Copy (DestinationFile) 6 w4 u. y/ }  Y; b4 u+ Y
CopyAFile = 1
/ E/ M5 f" Z: n% @3 e  ^, C, MElse
9 T& v* e, E1 R- cCopyAFile = -1
- |! F5 b) Z  r' ?4 zEnd if
! G" w8 E8 w3 f! Z0 s! TEnd Function $ M* Y" ?: T" a+ b6 |" Y8 a

1 M0 f! W6 z. F2 U( j' q'文件移动
, k+ V0 `- s/ `Public Function MoveAFile(SourceFile,DestinationFile)
) z0 ]7 n# r* I1 m: BIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then % h* j9 ~' K$ s& a' Q$ [, d
objFSO.MoveFile SourceFile,DestinationFileORPath
/ P, E- i" e' p+ p6 Y: `MoveAFile = 1 6 ]* ^1 r+ g. D- v2 p) j9 K
Else / \# S& V! D2 ]0 h% M* R9 H
MoveAFile = -1 4 ~4 k7 E. p- v
End if , J; p* U  s# x! z, X$ B2 ?
End Function , I  D  B; {! j* n4 n

9 O5 f- w' R* J3 x' j: `! V'文件是否存在?
4 G2 Q" h2 G  T: \Public Function ReportFileStatus(FileName)
1 R) U  @, R+ n0 v: RDim msg $ D5 {) T! ]2 F6 g: X  r, j
msg = -1
& T' s3 q& r0 G: bIf (objFSO.FileExists(FileName)) Then
5 O8 p; a1 O3 ~+ O1 v- wmsg = 1
% C& e" z! ]5 x9 uElse
2 c! v6 O  b( L7 o9 s1 Ymsg = -1   c1 I7 V* B2 M3 O; S
End If 6 m, y7 p2 r- d# ^% m
ReportFileStatus = msg
* \2 m7 B6 ~6 D1 ?End Function
0 v) [. u0 j" T; ]; y7 D; N6 h
0 c. u2 j9 `# Q( ]# j'文件创建日期
5 L, a) B& H! r4 m; |3 d" ^Public Function ShowDatecreated(FileSpec)
( u2 l5 ]. L& K( E0 D. P& _8 {" tDim f 6 {' A* b- C) \
If ReportFileStatus(FileSpec) = 1 Then 4 a5 J; \* ~' O  r( e! s
Set f = objFSO.GetFile(FileSpec)
# |: f; v& }1 }1 J; B9 fShowDatecreated = f.Datecreated - L. M) I1 P: j# ?+ e0 E0 d. a
Else
3 r- ~' T2 A' {7 ?) a3 YShowDatecreated = -1 - H* Y$ K5 H& K- f  \; L
End if
2 o( t! C4 H* D' @; BEnd Function
9 _6 }# `2 z# U2 L7 M, H. A* A" o1 R7 u1 I
'文件属性 . N' O- ^& K* m* N
Public Function GetAttributes(FileName)
2 b- e( y- J' ^& _7 Y1 EDim f
( o$ S/ }9 G: H& O; p3 `Dim strFileAttributes $ g$ Y3 y/ Y, t9 N! G
If ReportFileStatus(FileName) = 1 Then
$ R+ x2 L' R& Z$ ISet f = objFSO.GetFile(FileName)
1 k& [! _$ P2 }' Qselect Case f.attributes
' L# t& t5 j: a3 ^/ P7 J- LCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
, f# Y+ Y( {, v# @7 g7 t  q) XCase 1 strFileAttributes = "只读文件。可读写。 "
+ W9 [- J( [5 O! QCase 2 strFileAttributes = "隐藏文件。可读写。 "
# E8 b2 {8 k; @! ]Case 4 strFileAttributes = "系统文件。可读写。 "
+ Y: k, p+ E1 m, r% U% {% y; {Case 16 strFileAttributes = "文件夹或目录。只读。 " * P% i0 S3 }- f" ?, Z
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " - {7 V) f$ R/ L+ n, A
Case 1024 strFileAttributes = "链接或快捷方式。只读。 " 2 H4 ?. {! e# \# q/ i* W
Case 2048 strFileAttributes = " 压缩文件。只读。" & }6 \4 D3 g" s( h9 U" r1 N& y
End select 1 T$ f; J0 _7 M* j
GetAttributes = strFileAttributes ; c9 {1 B/ S, r% ^
Else ! Q% @: A2 A4 m' i
GetAttributes = -1
2 T) s- @9 o6 U2 w) {& QEnd if
/ W# f  A. N. G% Z7 o+ g& b- ~End Function . h8 ^7 ]/ Z" y  v+ K

1 `" V0 D1 B( G0 k& @# Q8 J% D3 B'最后一次访问/最后一次修改时间
; k& {) ?, ~" k6 dPublic Function ShowFileAccessInfo(FileName,InfoType) + n* f) {" G2 _# R) X& [* t4 Z/ ]
'//功能:显示文件创建时信息 : n$ Y5 f/ ]) R0 Z2 [
'//形参:文件名,信息类别
5 n. r' `0 ]2 ]9 J9 D'// 1 -----创建时间
9 t( d. h4 r- o- e'// 2 -----上次访问时间 ) e6 e4 @/ p+ p' e
'// 3 -----上次修改时间 $ f, a. J6 u! W; B
'// 4 -----文件路径 ! V4 M4 y. A) ~1 P6 H
'// 5 -----文件名称
4 j1 G5 V, P; A4 R9 j+ [1 j'// 6 -----文件类型
$ U- b" g9 P7 h1 q$ }" \'// 7 -----文件大小 / Q0 L) S& K7 e2 Q: q% E
'// 8 -----父目录
* l: G( y5 I, ]( j% |2 @' c'// 9 -----根目录 , L# Z. ~; B+ V
Dim f, s
) p" q. {6 c1 I8 s/ r1 oIf ReportFileStatus(FileName) = 1 then
( [# i8 S# c& I0 F6 lSet f = objFSO.GetFile(FileName) $ q" o7 h# T) \; h8 s/ ]) D
select Case InfoType
8 A+ o9 s7 Y3 {+ z5 w" }% tCase 1 s = f.Datecreated $ Q& S1 A' F3 k4 J& m
Case 2 s = f.DateLastAccessed ! J4 I1 z, M4 {9 L
Case 3 s = f.DateLastModified / y  K' I6 _. \' |4 j  U
Case 4 s = f.Path
8 Z6 h! O6 q5 H5 rCase 5 s = f.Name + r; V* a6 x- H$ v
Case 6 s = f.Type + D; m* D- g  o3 n' U& y
Case 7 s = f.Size
9 M' N2 b& @3 h, ACase 8 s = f.ParentFolder 6 C" [" z; q( ?. }4 P
Case 9 s = f.RootFolder
. A+ J/ ~+ X$ |7 |; B8 O4 Z% wEnd select " S* m5 L! b! K" s9 B$ n
ShowFileAccessInfo = s
5 }4 j" p5 X6 x; RELse
: o7 t2 w: s+ S; `: dShowFileAccessInfo = -1
. V) w. `) d( SEnd if + J# J1 P! Z! y& F8 E
End Function + z. a9 g( x2 }5 r7 R% Y  x0 R

3 ~, |2 Z/ q& L* y; P2 o; V'写文本文件
+ L2 Z/ L# L% a9 p1 W, M3 o, LPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
. N. Y5 D3 y( T7 p; E: YConst ForReading = 1, ForWriting = 2 , ForAppending = 8
  ~7 O% v; }& T0 Z* ZDim f, m
. O) D+ x0 q9 M0 Z* Fselect Case WriteORAppendType
$ d2 [* g6 Z7 [1 uCase 1: '文件进行写操作 % W2 z" G: h, |  K
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
4 ^; ?- q8 T7 w6 I9 Yf.Write TextStr
/ F* R6 k5 Y6 v; n! u, Bf.Close
& X! X, C$ i' l% c: f! s2 dIf ReportFileStatus(FileName) = 1 then + Y6 u$ M, A! f1 Z
WriteTxtFile = 1 # F3 U6 G$ F) ]  z" U
Else
. \  H' O+ q0 z+ c, M8 K$ o  JWriteTxtFile = -1
2 h2 h* G, Q+ J; w- l/ p# VEnd if 3 q' f$ ^4 B4 Z/ `
Case 2: '文件末尾进行写操作
6 J8 f" U. ~0 `6 n! O  K+ }5 ?If ReportFileStatus(FileName) = 1 then ; l- b3 [6 ~* L
Set f = objFSO.OpenTextFile(FileName, ForAppending)
! L. N. t4 C  }2 I# f# x$ N  Rf.Write TextStr
% B4 ^9 a8 W- K& X& A1 g7 R( bf.Close ' P9 K8 R$ `/ Q: O& \
WriteTxtFile = 1 2 V! l% Z+ G% b1 u2 ^- h$ ?, n
Else
' H& U) u, T2 cWriteTxtFile = -1
- N+ v6 e; u  D( P6 X2 Y  n, aEnd if - z/ w4 X/ {, I+ I! a
End select
$ {# Q5 p1 I" K! U* d9 mEnd Function 3 i2 [" j, R" {* K3 [' a; A
* F/ r: _$ j3 |- h3 j7 [* s$ @
'读文本文件
( b$ J  ^, g7 ]+ j, {! }% ?Public Function ReadTxtFile(FileName)
5 f6 Z/ d9 \$ O; A. ~+ VConst ForReading = 1, ForWriting = 2
" `% Z& A7 H  V: TDim f, m
6 u% {; j/ e% K) ?3 CIf ReportFileStatus(FileName) = 1 then
/ L9 l* p- V; wSet f = objFSO.OpenTextFile(FileName, ForReading)
0 \- b5 t% B* J, J/ S1 \" Hm = f.ReadLine * t) V4 `$ @6 u* A6 s
ReadTxtFile = m - z3 y" d/ [- i- C2 s7 b" T  y
f.Close + t/ n8 W0 d. \: Z2 ]
Else
: L" Q/ Z$ a3 Z7 S- {7 BReadTxtFile = -1
5 w' ~* @6 R% A4 Q. Y8 h7 C2 }End if
5 h0 @1 f% q% v. U2 f: DEnd Function
% R" i9 ]+ X( A  o% d" |' k, c# L" f' F6 ~0 u
'建立文本文件
) A2 N0 T; Z# I7 V0 X& r6 T5 o& a4 H* d1 {
'=======目录操作======== ; E" q7 G& O. o$ |: t9 K) v
'取目录大小 " c$ [9 j) o6 ~( E
Public Function GetFolderSize(FolderName) # M/ I! ]0 p* p8 {7 {3 o
Dim f
; R/ ~* z" `+ K! Z" A" dIf ReportFolderStatus(FolderName) = 1 Then
: U7 V2 g2 |8 kSet f = objFSO.GetFolder(FolderName) % s' n+ A( \& I7 H$ N+ W( v& W
GetFolderSize = f.Size ) a7 [' [2 V( n+ a: G& R
Else
# I2 h! C* P  b- e3 U9 C$ M9 o% cGetFolderSize = -1 8 s2 s4 K2 |* C4 |% O
End if
) ^& k0 n: ~$ t1 O* R3 NEnd Function / s( l2 Q1 A* ]0 C1 u
2 K: k, J  ~9 A  |! r
'创建的文件夹
1 N" M3 F9 i3 x$ XPublic Function createFolderDemo(FolderName) 1 [! n3 E& l6 Z4 Q) c' y+ @
Dim f 1 s( P8 w+ l* E8 t' @! [8 j
If ReportFolderStatus(Folderspec) = 1 Then
0 F2 d1 z6 S5 l4 c4 \6 d. t& X: Q: GcreateFolderDemo = -1
% f. r* E" l5 Z; X, ^* IElse
" |7 E: h: J$ p' cSet f = objFSO.createFolder(FolderName) ( h# i) X8 ?$ h: Q, N
createFolderDemo = 1
0 Z$ \1 r, j- |+ Q* C4 ^$ ^End if 2 K( U% t; P9 w- i3 [
End Function
3 T% ?7 Y: r1 ]3 k
5 @: S/ B% z& F4 _'目录删除 % _4 E! I* V* j
Public Function deleteAFolder(Folderspec)
0 S- r7 P! e! |; M* RResponse.write Folderspec & I$ D& ]2 M3 r: d9 T  d
If ReportFolderStatus(Folderspec) = 1 Then * a  A- L6 j0 T  q( [- j8 T
objFSO.deleteFolder (Folderspec) 5 q4 b' m3 W/ [5 `8 q! f( ~& n/ O+ i
deleteAFolder = 1 4 b/ H6 s& d2 M+ t" Y( V4 T  u
Else
$ F1 K) A8 m4 Q, I& f5 r0 p/ }deleteAFolder = -1
6 H5 i, g- b. t! X; D* ]End if % K* t& A; O% O! j& g
End Function   u. I5 V, Z. O1 K/ P1 y( ?
6 p5 d) s5 Y& Y
'显示目录列表 ! F  E! L0 d  K' p
Public Function ShowFolderList(FolderSpec)
5 ~. m) C$ g# q' R8 x( E! XDim f, f1, fc, s % |  N9 {3 I( a
If ReportFolderStatus(FolderSpec) = 1 Then ) p+ g. i' Y% `: b1 H
Set f = objFSO.GetFolder(FolderSpec)
1 \* p7 p1 l- k/ u) x/ mSet fc = f.SubFolders
; _1 ~. K4 E  w  M7 [For Each f1 in fc 5 c3 d" J- |! l7 u! g  n" [
s = s & f1.name , _! J! d+ V6 [, x6 \+ z
s = s & "|"
3 q/ F0 x1 i7 W$ oNext
: z5 |2 M3 B9 u* y( KShowFolderList = s
8 C( ^/ u- P3 D3 Q  o. Q. S% UElse
8 Z1 \% e1 G3 R$ |$ sShowFolderList = -1
$ r9 I. b" i4 }1 H' k3 dEnd if 4 c& F, u5 t4 j9 Z0 [6 Y: Z
End Function
8 T% g9 g1 S( @5 g8 k# ]& ]: c. U* z; N) M! v/ G2 F0 U
'目录复制
& n' y6 T# d' z" g, ], DPublic Function CopyAFolder(SourceFolder,DestinationFolder)
  o. \/ k# }; V! F6 w, h8 I7 vobjFSO.CopyFolder SourceFolder,DestinationFolder 2 E) f* x3 P) G5 e4 ?
CopyAFolder = 1
9 Z1 \" D/ E/ W  B  x" |! @CopyAFolder = -1
7 b2 i; ?1 F& W, M8 g( GEnd Function
6 s5 {2 Z7 q) }8 h
/ S. |3 c0 U3 U3 t% Y* z& r
! x( @. D' K/ t# d( g9 J2 [$ P'目录进行移动
6 \" m& G: }+ fPublic Function MoveAFolder(SourcePath,DestinationPath) 1 z& c$ ?5 w! x! r
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
& n& L2 v; b# d, w. LobjFSO.MoveFolder SourcePath, DestinationPath
% K' L5 m* t) D$ s7 r* _5 i" sMoveAFolder = 1
& f7 C3 O+ e! ]Else
% C8 v4 n' B6 E  N2 C5 lMoveAFolder = -1 6 R( \/ z3 \0 t' j7 @7 O# w
End if
  i5 ]2 w! A  J/ s0 t: d# iEnd Function
  B( ~; G9 ^  N2 ^9 Z" `+ x$ Q0 X  J9 ]* m& a0 S- C4 `
'判断目录是否存在 2 p5 ^+ u; x2 {5 c; y
Public Function ReportFolderStatus(fldr)
1 \+ [- _0 x: b1 EDim msg 2 }# L1 h0 Z, t  ^5 H" T! k# d/ f4 |* [+ H
msg = -1
% Q0 A# N- P7 C. FIf (objFSO.FolderExists(fldr)) Then 1 d( E4 p( j* x
msg = 1 : Y% s& X6 w% @
Else 2 I0 c/ \8 E/ g* |  g
msg = -1
: r/ Z7 A$ K& \4 `) }( @% p% bEnd If
, C5 p9 E5 ^: _  n/ ]ReportFolderStatus = msg   K* [( O" I2 K; A
End Function + V4 ]( [; I; O, K
' n3 L  ?! ~' `# P, q
'目录创建时信息 2 C! w$ I; c! c
Public Function ShowFolderAccessInfo(FolderName,InfoType)
: ^8 N: R1 Q6 n'//功能:显示目录创建时信息 ( r" h5 Y9 Y& n
'//形参:目录名,信息类别
/ W5 W% p. q  k; S7 f9 I7 i'// 1 -----创建时间
% x( U# ]4 b' w6 W  C, e/ y'// 2 -----上次访问时间
3 ~1 \2 ]7 i3 i" n" q'// 3 -----上次修改时间 3 ^% Q) L3 |" S5 @* G
'// 4 -----目录路径
" J: a; L3 s# t: L$ N'// 5 -----目录名称
9 ~* q( K2 t' K6 j& v7 ~'// 6 -----目录类型 * s& @8 S' t; K% J6 o% ~0 r, |
'// 7 -----目录大小
7 l0 a" W9 n: }, V% g'// 8 -----父目录
" s* N# l" ^9 h2 b) {- T'// 9 -----根目录
( d) m; |1 [, s2 K) w3 eDim f, s
" Q" x3 ?" C7 ]If ReportFolderStatus(FolderName) = 1 then
/ A) ^4 X/ r5 i" `; ]$ {# E! u9 nSet f = objFSO.GetFolder(FolderName) 7 f( c/ R" v" S6 J
select Case InfoType
2 N# M' }% |2 [. B$ M+ }Case 1 s = f.Datecreated % {* ]2 p# A) W  p. ~7 t
Case 2 s = f.DateLastAccessed
0 M4 H* Q6 q  f4 ICase 3 s = f.DateLastModified
- L# n% }' m+ q: }: o, U6 NCase 4 s = f.Path 9 y3 s2 L4 T% K5 C  S) H
Case 5 s = f.Name 5 M/ ], _2 F% g( k8 s7 b
Case 6 s = f.Type ' z: ~0 Y8 j9 k( \3 W
Case 7 s = f.Size   U6 d+ r8 `4 i) b& ~$ G% {
Case 8 s = f.ParentFolder
6 H3 [0 }6 v7 a  iCase 9 s = f.RootFolder ! I  E: V6 p$ p( U
End select ; K0 x4 t3 R% Q
ShowFolderAccessInfo = s
6 g/ U) q3 H6 i0 v. z. QELse
/ ]6 n, q. V! Z1 ]/ I% mShowFolderAccessInfo = -1 & q! B4 O- @1 C: }$ ^7 A6 Z
End if ' a' l: Q2 G+ K( i
End Function 2 [9 [% H- V8 W; ~4 u
  I; X7 f0 c6 ~
'遍历目录 ( i1 g4 k$ H" X. ~9 R! q
Public Function DisplayLevelDepth(pathspec)
/ P4 k7 o5 q* tDim f, n ,Path
) E7 v. M1 P6 A" }! {* [! _Set f = objFSO.GetFolder(pathspec) 5 e8 `% A; @% m# m$ B% S
If f.IsRootFolder Then
0 [; [0 x" K6 uDisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder * r9 a' M, e" e: L( U/ B# ~5 @
Else
2 u8 k; }: v7 x. eDo Until f.IsRootFolder ' S, H' ^; R" q
Path = Path & f.Name &"<br>"
. r9 k/ N3 D5 PSet f = f.ParentFolder . o2 e5 ^. Q8 T8 B
n = n + 1
: v# {& ?7 C# e( u9 u7 BLoop & H) ^( o8 {9 m& {
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
0 }# L* B$ t9 N1 l1 d# ^0 _End If
4 M" I1 y, D$ M. u  ]6 jEnd Function ! R% R9 K- F4 P  i5 L6 P% f) ~
, K3 h3 l9 c& R
'========磁盘操作========
8 \. `# Q: V# R'驱动器是否存在?
/ c6 w, P. j) }, ^1 A! I9 _- E% YPublic Function ReportDriveStatus(drv)
0 ^: a0 K$ e/ r2 J$ E8 m! LDim msg ; G# w( f. h4 p
msg = -1
# X; g/ {; S  l" X) R/ c6 O4 PIf objFSO.DriveExists(drv) Then $ P7 w$ a1 K# M/ E
msg = 1 $ }7 \. i# D  x
Else
% B( e7 Z5 U- Y9 @* V4 Rmsg = -1
. P% c8 V% Q) MEnd If
; F: J0 O- K  ]& m" ^ReportDriveStatus = msg
: t' m# Y+ i2 t! W% w& qEnd Function 7 K% M0 E/ ]' f0 e6 v: `( G0 v5 l
( Q* o% z* u  Y( f
'可用的返回类型包括 FAT、NTFS 和 CDFS。
4 J  f9 V$ s; iPublic Function ShowFileSystemType(drvspec) 1 n2 G+ `! k! h& |! }3 n
Dim d
' a1 k( m7 z& j& |0 n8 n" ~- S3 RIf ReportDriveStatus(drvspec) = 1 Then
( G* Z; e% l* S- G  P% \Set d = objFSO.GetDrive(drvspec)
/ I3 E# J) h( H3 MShowFileSystemType = d.FileSystem
& R) }1 }) {, A7 s( T) ]7 NELse , T) }0 [/ q; C$ l2 W
ShowFileSystemType = -1
0 a& E' |( a  w. s4 gEnd if   a6 U- W# a" N  N3 Z( q/ ~' S
End Function * Y# y. w$ h0 Y$ C; [
End Class 8 I5 \- G+ e# C
%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

Archiver|手机版|【高州情】

GMT+8, 2026-5-10 22:49 , Processed in 0.026470 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部