【高州情】高州人深圳站

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

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

ASP文件操作大全+ W/ d# p  M: j4 j' r8 H- S
<% 3 {' @& F- s6 m" o. ^7 r
Class Cls_FSO
" C, i9 E, }7 r; B+ J, PPublic objFSO . n. `, u/ @+ Q: E  Q' I( G+ i
Private Sub Class_Initialize()
& R( ]8 I" z7 q+ |; [9 \. H: F1 n3 U; eSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
0 r3 ]0 L- T+ L3 D; ?7 ]End Sub
* w& S2 t# ~- T9 B, `4 gPrivate Sub class_terminate()
$ X; n9 y9 a9 A! Q7 l6 Z: qSet objFSO = Nothing
- S$ O. u! O% A6 KEnd Sub
' q) y7 x& l5 l3 X
) C) b- {; i: u: f+ O! v3 H' C'=======文件操作======== & R, l9 i0 s# O
'取文件大小 ( l# E5 |2 J, ~9 o
Public Function GetFileSize(FileName)
8 K* v2 |# ^8 \& |1 oDim f
2 }/ X" q2 Z* a' e% |1 [) QIf ReportFileStatus(FileName) = 1 Then & M" n7 l. T( O4 {7 u
Set f = objFSO.Getfile(FileName) - P2 u2 @- x4 ^/ c
GetFileSize = f.Size
, S* r0 E! i7 \# g1 `Else 3 f  J1 b# C+ B6 B) A
GetFileSize = -1 ( V* u0 y9 b: ~+ w( M, g
End if
5 b- B/ i3 k5 Z& E. TEnd Function
) K5 ~& r8 l# H9 G* g' ]% H+ h8 ^" Z6 V) u2 U+ ^! ]" B
'文件删除
0 ]' K; E+ u: V* K  ?; k! a; PPublic Function deleteAFile(FileSpec)
7 ?# g  R& Z; [If ReportFileStatus(FileSpec) = 1 Then
7 }7 Q$ \  m) GobjFSO.deleteFile(FileSpec) 0 D# B2 W) n5 e$ b# P
deleteAFile = 1
6 k4 `( ^4 E4 R2 z  MElse - x" K3 e+ u$ S
deleteAFile = -1
0 E* @3 F+ o$ S' P% [End if
. r; |9 ^( @5 L0 H: w1 ?End Function
8 a4 P+ @$ O% ?* \0 p- O0 @! z5 |, C! c; Z' Q
'显示文件列表
" J: p4 m; n( VPublic Function ShowFileList(FolderSpec) - {% g! N. |" ^/ ~; y3 w  C% Z
Dim f, f1, fc, s
- e9 J+ c7 S  A5 pIf ReportFolderStatus(FolderSpec) = 1 Then
, j/ Z! {/ c8 USet f = objFSO.GetFolder(FolderSpec)
8 @) u  O5 Y8 V( {Set fc = f.Files ( R4 H  \& d7 w* d5 B: ?
For Each f1 in fc
9 S/ ]& n% Q7 s9 Q% b7 D+ l+ Gs = s & f1.name
, p6 s# [7 [) Vs = s & "|" $ R" n; C% _7 h! F* k' q
Next ; w! o) ]  n, d6 t* i7 u- {" \
ShowFileList = s $ A& N# {% R+ C
Else
/ D  g, N4 p3 d& Z7 u5 l% M0 e! {3 hShowFileList = -1 1 U$ B- t! w  r1 j, Z3 p
End if
! l3 c: i: l8 p# d) r+ ]End Function
! _4 a$ u0 s* d. [$ ?# g9 w5 f  d; n1 O* K9 |% K
'文件复制 - J7 b# k6 B' `
Public Function CopyAFile(SourceFile, DestinationFile)
8 o4 h9 ^- l* N1 P' X; g5 @/ J( xDim MyFile & \  ]; h9 h+ E4 B0 I
If ReportFileStatus(SourceFile) = 1 Then ' _6 h- Q8 D1 q; H3 ]" k, H
Set MyFile = objFSO.GetFile(SourceFile)
- A% G$ B( `- i: uMyFile.Copy (DestinationFile) 3 a" k/ e) E4 t) V  L
CopyAFile = 1 * D' i' N4 i# p; M
Else ! y4 \* k# k2 F0 P+ w5 O
CopyAFile = -1
0 Q3 j2 N# f" b7 h; W$ s" u! u2 oEnd if ; k4 R. j* n2 K  ^0 U  j& k
End Function
; @8 u, g" @6 J: {& E- q, i9 ^& o" p" R9 @3 b1 J6 x0 q
'文件移动
( l  {; \$ S) K. s- [) m8 iPublic Function MoveAFile(SourceFile,DestinationFile)
, b; X- l+ K) h, }& f; uIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
9 @& S& g. U; M$ VobjFSO.MoveFile SourceFile,DestinationFileORPath 5 K1 ]: ^: s& y9 M
MoveAFile = 1
! P- _% D! q: [% o8 c. n6 B4 DElse ! n) V- s1 U9 h# Z; S# L2 D& y1 x
MoveAFile = -1 0 W. F4 Q0 f8 L/ e) T* N
End if
) E& K7 m$ ]( F. o" g! jEnd Function + O6 {/ s" Y! J
3 t+ \, n& H8 m! R& k$ [- t* p
'文件是否存在?
4 H# V& E, G1 g: c) nPublic Function ReportFileStatus(FileName)   _, p) i7 x' a7 j
Dim msg 0 x7 R2 B0 k0 R# u6 i) \
msg = -1
* B0 b7 ~/ y: rIf (objFSO.FileExists(FileName)) Then
2 w* ^( l# W" h2 e  a. dmsg = 1 * O" [5 G5 N1 ^/ k5 p, c
Else & ]$ x2 F& ?2 I# B
msg = -1
1 f, h! P- q; ~7 R( HEnd If
- c2 r3 P; ^$ B8 M/ MReportFileStatus = msg : X" H6 K' m& Y5 k+ R- h$ i
End Function
0 ?. [- C+ p! H3 y# D( T) j4 `5 `5 }  w$ r
'文件创建日期
+ M9 y7 }% m8 SPublic Function ShowDatecreated(FileSpec)
' R; L  [1 w8 H: {1 ?6 @3 |# PDim f , {! ~1 M3 B9 D, T7 a3 ?. n" K2 d
If ReportFileStatus(FileSpec) = 1 Then 4 @( x' m& ~2 Q7 l
Set f = objFSO.GetFile(FileSpec)
/ X2 C. @# o: {# P% m+ Z3 C  o6 lShowDatecreated = f.Datecreated ; k! _$ k8 p, ^/ K
Else & E1 O2 ^1 B5 j( y
ShowDatecreated = -1
8 g3 D. J/ G; P; w6 DEnd if 9 I. B- k% a5 ^' P8 [: ]5 `% \
End Function
( v# L, f" L! A: {% R0 S6 A
- b0 ^9 H9 L8 t; G" `; v' x'文件属性 & `4 g! `+ @' L: @6 N' p: T7 a) F
Public Function GetAttributes(FileName) ! n- |/ x4 D4 z) }* M& A" j% T
Dim f & Y% k. U1 f# O6 p5 Z) [; n
Dim strFileAttributes
4 r3 L+ r0 V1 v% O$ l7 IIf ReportFileStatus(FileName) = 1 Then ! q4 C7 ^* r! p$ h3 b$ e
Set f = objFSO.GetFile(FileName)
' T. L* n! W5 T, X8 Hselect Case f.attributes
$ E5 e: l+ D8 D8 JCase 0 strFileAttributes = "普通文件。没有设置任何属性。 "
  h( y: d0 W- {1 oCase 1 strFileAttributes = "只读文件。可读写。 " % Y  ]$ b$ _/ E9 s- m, Q; A
Case 2 strFileAttributes = "隐藏文件。可读写。 " % g0 m2 J. y/ H! E
Case 4 strFileAttributes = "系统文件。可读写。 " ) V9 I' \. q3 i( e3 q9 {
Case 16 strFileAttributes = "文件夹或目录。只读。 "
1 p1 _  n* w% d% y4 g" wCase 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "   E5 @: I: Y8 j  s0 H
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
$ {) A) X% {7 }7 _' oCase 2048 strFileAttributes = " 压缩文件。只读。"
3 L4 r* a* _# c* h; z' {% @End select ; C7 _+ r6 u- r& T+ g; V1 D/ n$ I/ U
GetAttributes = strFileAttributes ) b# g4 w- n+ \& }% u
Else ( E5 D) H; f- t' N
GetAttributes = -1 . R6 c! S; a9 `
End if 5 U8 o3 W7 d9 U6 E. c% g$ j
End Function
/ E* t  A+ |; A# ~+ B! e/ s2 ?) R5 n! w) y, f- B
'最后一次访问/最后一次修改时间 " C* E2 L5 |9 k% g& ]  l
Public Function ShowFileAccessInfo(FileName,InfoType)
" |# l1 c6 e. K4 K9 f'//功能:显示文件创建时信息 ( S5 l; Z- F% i! m, n2 O
'//形参:文件名,信息类别 4 j9 S) n4 W( d- ~  w5 l. u
'// 1 -----创建时间
) B0 G- y. F( o'// 2 -----上次访问时间
9 d, s7 {/ j; h  m  j& A'// 3 -----上次修改时间
$ a3 v# W0 n4 G1 C'// 4 -----文件路径
# ^, V: t- F: U" H0 v0 O1 y'// 5 -----文件名称 3 v5 D" |  T! o* m9 h5 f0 c9 A
'// 6 -----文件类型
8 A* c7 X) I+ n. Z) v'// 7 -----文件大小 1 N% z/ \( u4 T, x  e4 P& W
'// 8 -----父目录 % S8 k2 m+ W* d4 M& J
'// 9 -----根目录
* f8 W, k% q! D0 I& J7 Y( Q) XDim f, s
: i  C4 B' O$ S5 Z1 ]If ReportFileStatus(FileName) = 1 then
9 Y: e4 c; L0 `& ~* MSet f = objFSO.GetFile(FileName) 2 n- d1 e, b) t6 ^5 K
select Case InfoType : K- e+ _% e2 i* A& c
Case 1 s = f.Datecreated , V4 z1 Z5 O0 t& e
Case 2 s = f.DateLastAccessed 4 X) f& U* O- p8 ^& G" G
Case 3 s = f.DateLastModified : U3 Y% V: D3 X! M# |+ z
Case 4 s = f.Path " J: F+ N% {; E$ Z" z
Case 5 s = f.Name 4 S0 X& m, @3 Y/ @8 o- l" X
Case 6 s = f.Type
. F  ~3 p$ l* h  N. |2 MCase 7 s = f.Size 7 W2 ?2 ~2 |5 H! z; D# `( ~
Case 8 s = f.ParentFolder
+ x5 k. K9 F& I$ D" g+ CCase 9 s = f.RootFolder 3 Q' R* d+ z) i4 P; c  \
End select / u. l' g8 z4 _0 i, ~
ShowFileAccessInfo = s
  I9 f/ T2 m4 Z2 f8 Q/ }1 gELse 0 F# n& d" J% G" t* }; m' F
ShowFileAccessInfo = -1
- W; u" z2 r- ^4 ^6 L9 w3 [End if
8 l4 V: t7 \8 ]) pEnd Function
7 n/ ~% {2 g6 M* i3 v! |, l2 }8 f. S: V4 O( ~' X# o1 m
'写文本文件
  N, n5 z3 Z' L. CPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
% L1 l( K! a1 C$ \/ m( R0 ?$ ~3 SConst ForReading = 1, ForWriting = 2 , ForAppending = 8 / h  X/ A! E, h, j
Dim f, m
/ D, t* i2 R  @, D0 |# Hselect Case WriteORAppendType
% L9 {& Z1 I% J6 R" H5 x9 gCase 1: '文件进行写操作 5 ?: W$ n. T% D' B3 P
Set f = objFSO.OpenTextFile(FileName, ForWriting, True) $ ^4 l( b$ p3 T! F, W
f.Write TextStr 5 y3 m8 i- C. M# {+ ?
f.Close   D% _6 Z( \) q! D& c- O
If ReportFileStatus(FileName) = 1 then # v6 c: g' A( B$ k" l
WriteTxtFile = 1 # k6 X2 q! ?: c+ l: ~
Else
$ e6 o8 C9 @0 P( s- y' EWriteTxtFile = -1 ; F0 C( W" o; |% y# G' I
End if ! P1 G! r: y! I4 H5 K6 x& T& O$ F
Case 2: '文件末尾进行写操作
! S( T5 z/ j: iIf ReportFileStatus(FileName) = 1 then
6 e7 ~. C) ?- |% _$ I. ^9 h" J' Y, gSet f = objFSO.OpenTextFile(FileName, ForAppending) 8 O! ~9 v+ W+ _2 m$ U" U
f.Write TextStr 5 G9 D1 o9 ~3 V2 W- V  @
f.Close : }, w3 b9 |" s0 G( a( \4 S
WriteTxtFile = 1
" H, t% N% e8 NElse
5 w9 ]# x  Q5 f  P+ w% U. T8 m2 p) rWriteTxtFile = -1
" V3 m& I( \2 FEnd if # }+ H8 t6 W) ]' N& n1 @; a
End select
' S0 i4 ?" l  k" y& yEnd Function
/ X1 L! m! c! W; a0 v
0 b3 Z" @6 U# F6 x; A' Q'读文本文件 - s  b: r; H+ G+ C& z  c6 ~4 C9 h
Public Function ReadTxtFile(FileName)
4 F" m7 W$ `- W$ x6 F5 }" _2 YConst ForReading = 1, ForWriting = 2
- I. V! N$ I. l& R2 L$ UDim f, m
! e& g2 a  ?" S( q- pIf ReportFileStatus(FileName) = 1 then 5 y4 I; f" J* U
Set f = objFSO.OpenTextFile(FileName, ForReading) - b- C, a& G/ [3 T& j) d
m = f.ReadLine 9 ~# o% R3 x$ J. Z2 G) l
ReadTxtFile = m
0 e$ B1 W" }+ x. {f.Close
3 L3 T$ b  @4 ~. U0 F: hElse 0 `, \2 y  A# ^" V! f
ReadTxtFile = -1
0 b7 M# X: f, r- bEnd if - j' f) O4 c, b  i" D2 H
End Function
/ P# u! U6 L2 Y9 t, Z% v( S' H9 L3 X' Q7 h/ W
'建立文本文件
  D3 ^+ w1 H- \1 @' c0 @- y6 @. Q- V# @9 C5 \9 ^! O- G: d
'=======目录操作======== " ~" q, g4 O6 d0 m* d# |: E
'取目录大小 ; Y6 C3 x  b0 A
Public Function GetFolderSize(FolderName)
. V; R, O' q3 P8 jDim f
6 n+ J  F4 F7 d4 @+ y7 j9 eIf ReportFolderStatus(FolderName) = 1 Then
' E# ~' J3 J4 a! @Set f = objFSO.GetFolder(FolderName)
0 y0 o. p3 L5 \3 E% eGetFolderSize = f.Size
3 @- ^: c, Y& VElse
+ c% l/ o: w6 I* o$ O/ c- ], e1 }GetFolderSize = -1 . y2 Z6 x% q; r$ f
End if
4 l) N: [+ E( v4 a: o. g: iEnd Function
0 i5 \' H4 t: s6 L9 L3 o9 l9 Z$ _2 C& @4 F9 `: j* `" ^6 f) q
'创建的文件夹 ) Y4 o3 @0 S) l/ v0 z
Public Function createFolderDemo(FolderName) & U7 V0 j& f/ e
Dim f
# E+ o3 d6 R. w* a! yIf ReportFolderStatus(Folderspec) = 1 Then
+ r! u! t+ M" O+ e, P& TcreateFolderDemo = -1
; z5 T3 f% s4 h" IElse ! E0 r9 N; }8 h5 x3 K
Set f = objFSO.createFolder(FolderName)
& {! }4 i2 w2 E- V7 wcreateFolderDemo = 1 / C" Q& p- u9 g- N5 H
End if
& j; z) W7 K3 }( \2 Y% nEnd Function 9 p; \5 d. E* P% h0 _
' n0 ^+ y9 E" L& M1 E  Y
'目录删除 1 T: s/ ?' T4 W! F/ V( S: A; m# S
Public Function deleteAFolder(Folderspec)
) U) Z' Y; z9 e. H" N& q9 e' R, LResponse.write Folderspec
% n* H! L) o$ RIf ReportFolderStatus(Folderspec) = 1 Then
$ V/ P- p$ y- d, }* _# M: T) j* ?% yobjFSO.deleteFolder (Folderspec) : m- l& i0 @& Y( O) J9 L
deleteAFolder = 1 6 M8 g: x4 O  m, D* F) R
Else
5 S  V+ n# J8 r  XdeleteAFolder = -1
; Z1 ]. O, u: DEnd if " P. ^, y& B5 @% t! V
End Function   d6 C3 t' o5 i/ c# b9 c; \% g
0 k2 h. Y$ y) V/ Z3 m# U  [) ]7 n4 @
'显示目录列表
+ R5 A5 e. a) KPublic Function ShowFolderList(FolderSpec)
! ^6 w, b$ w3 J( o% ^2 n- B& r, RDim f, f1, fc, s
5 _. A# j! t0 Q2 OIf ReportFolderStatus(FolderSpec) = 1 Then 2 b& F) |" J2 }7 ]0 F: j0 \* r
Set f = objFSO.GetFolder(FolderSpec) , l0 A2 |# U# F, c9 k. [
Set fc = f.SubFolders
. P' Y: x/ m& V% ]$ DFor Each f1 in fc
1 _3 z# e- D& ?8 X! Vs = s & f1.name
8 ^+ A/ L- Z# ^6 m7 l2 G. Ls = s & "|" ! M8 G8 V# h9 s
Next
4 i# ]0 |. E; v; W( JShowFolderList = s
$ j4 p1 s/ e" x/ H3 k5 EElse
- G6 m* h9 o$ PShowFolderList = -1
$ {* [' M+ \- V! O7 bEnd if ' k# W. B( R' X$ c4 N
End Function " F) F" x  D, s& J" C

/ \7 g7 @4 b' Y1 ^'目录复制   F9 U/ C, ^! V0 f) [2 n
Public Function CopyAFolder(SourceFolder,DestinationFolder) $ i: g, h6 l& c: C) }
objFSO.CopyFolder SourceFolder,DestinationFolder & o2 X* d+ Z+ D& D
CopyAFolder = 1 / N' _0 d& @9 @6 P  q
CopyAFolder = -1
1 n2 I' `) v8 r9 b  {9 hEnd Function
% ^. ~# Z# I) e5 F3 }. W( I  P
/ [5 w7 a% B; g# P! O) |9 [; w
% G7 G* _& a! A  @( {$ e4 w7 }/ c'目录进行移动 " t: C; r0 x) n- }) X. I$ i& I7 \% }
Public Function MoveAFolder(SourcePath,DestinationPath)
' K2 ]3 H3 T( e* L8 BIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
, H) e3 j% L/ K; U1 ?0 g- u  jobjFSO.MoveFolder SourcePath, DestinationPath
) c4 O  z9 _8 [8 eMoveAFolder = 1
) ]* U4 e% Y3 x# \5 @Else
: {  O  X% D0 KMoveAFolder = -1
5 k* X0 l& O- e8 Y8 n9 {End if . O$ [- n: a# o4 Z! M! s
End Function # b" _' q! n" e5 O2 M

7 o0 m& ~2 D5 d0 }7 ]8 o! Z'判断目录是否存在
- i- }% V/ [$ C2 @2 f  g; v, g* WPublic Function ReportFolderStatus(fldr)
- F# [9 z6 s( c# ?% `2 e+ |& NDim msg 4 p+ v6 c- ?3 y% `- b) J0 F
msg = -1 % g$ w$ P2 L) ^) E9 h( S3 }& ]3 O0 H
If (objFSO.FolderExists(fldr)) Then 4 X( V% ]! j! Q( n
msg = 1
$ d; H. K* ]4 `$ VElse
+ n3 y" r' o8 t2 e. d4 y( C, `msg = -1 ' }: H4 A7 u, h* I: e
End If
4 v. X0 ~8 K7 v6 T( e# Y. eReportFolderStatus = msg   @$ P: Y9 t4 `; l* H, G
End Function
* E3 A' H5 R' p6 A% [7 L6 G% ]! s0 B9 [# n
'目录创建时信息
  j% e; b5 x4 e: A" e# ~Public Function ShowFolderAccessInfo(FolderName,InfoType)
' K% Y$ y" ]- f& L'//功能:显示目录创建时信息 2 N* i: n# o" Y% j6 f- P
'//形参:目录名,信息类别
" W  F: l. c2 x% b, N'// 1 -----创建时间
6 P# ~3 ^5 }, W% b7 ]0 h'// 2 -----上次访问时间
; P$ x  U0 K( J1 R; L'// 3 -----上次修改时间 " O3 \! H- @7 T3 G% y
'// 4 -----目录路径
( Z- H, W: L# Q7 A* Z" a5 I4 k'// 5 -----目录名称
0 f8 C1 j7 b' ?9 X; G+ f' M'// 6 -----目录类型 % T- w' g+ X( H* c7 \
'// 7 -----目录大小
; t) U$ {$ @+ h$ k, M5 C3 {'// 8 -----父目录 + \( d" U$ b$ n
'// 9 -----根目录 ' e2 ]/ _# W9 z" Y7 C) k+ D
Dim f, s 6 h0 A0 q- ^, _  S: ?3 e
If ReportFolderStatus(FolderName) = 1 then : j. f) H$ e! s+ y: k
Set f = objFSO.GetFolder(FolderName) 9 ]3 ~6 F" }, g# v/ S; w* i
select Case InfoType   E: `7 L& O9 S, h1 p; m$ T) b
Case 1 s = f.Datecreated 1 W6 S3 [4 [1 U  q9 O
Case 2 s = f.DateLastAccessed : n3 Y" K) T" q( i  N* p7 T
Case 3 s = f.DateLastModified
6 S7 o! S' \; Q1 F( H. X, X8 ~Case 4 s = f.Path & G% I5 g' O7 B( E! \! Y& u
Case 5 s = f.Name
+ ?7 Y# r0 M( w5 b' k' DCase 6 s = f.Type # f' m! y. s1 @
Case 7 s = f.Size 1 b5 c" n) C! O9 |
Case 8 s = f.ParentFolder
# C9 i% D9 C; R2 ^) I6 \9 c9 |Case 9 s = f.RootFolder ! x3 G* \  l" [: c3 F1 l
End select
* ^' O, {4 @% K8 F' B& s. [ShowFolderAccessInfo = s : b. U" n1 ]6 p! `' H% m
ELse
5 n' J$ S8 E, C; v. vShowFolderAccessInfo = -1 " A) ~: x$ g, e- r$ g
End if
* @- K6 L  D( Q0 _End Function : C1 e6 Y$ z% o3 ?' g
: {4 {$ W: c/ M* C+ a
'遍历目录 3 K  y9 B$ y7 |
Public Function DisplayLevelDepth(pathspec) 4 \, Z! A: d0 Z4 C/ f" V0 A" O
Dim f, n ,Path ' w8 _. @8 o8 B
Set f = objFSO.GetFolder(pathspec) % e( D' o9 Y3 A0 Q
If f.IsRootFolder Then * b4 Z  x6 F7 l8 x7 Y
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder 3 P8 V, I; D2 s) h6 ^- Z$ t' D
Else % @. m& [0 l! S0 I! H- @4 g/ J$ J
Do Until f.IsRootFolder
) N( A# a4 k- H/ I7 w# s. oPath = Path & f.Name &"<br>" 0 J! q* P+ r, o2 r& R4 A! E* I
Set f = f.ParentFolder 3 j  r" z* A- ]* `
n = n + 1
4 |& V0 y: k) Q; N6 `' Z/ XLoop ' r/ t: A- o: U. u
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
4 f+ H" d0 M# N; G1 DEnd If ) D1 ^" w+ y$ U' R2 O6 `1 e
End Function 6 j6 q7 a9 R( S0 |' ^3 j% T! O

$ ^6 W0 H6 o' `: {; M'========磁盘操作========
2 F, e- W/ t- ]+ t'驱动器是否存在?
9 e& {4 g6 J. z- g/ ]3 B4 rPublic Function ReportDriveStatus(drv)
- C6 ~; u8 `) b0 @2 XDim msg % i* a6 H4 O. H5 @4 `( l
msg = -1 % A' r+ y! f5 s. C& E
If objFSO.DriveExists(drv) Then
0 S' n+ ^& b* G7 hmsg = 1
5 j9 Q. r9 ?  ~( F! xElse
0 W' H  L6 v" C7 U8 G4 e5 w3 Pmsg = -1
4 c- |# E$ ~" o( ?3 @4 i9 |( pEnd If
6 r" v. d( {$ ~  u1 ?ReportDriveStatus = msg
( a3 P& ]0 k! y# r# \% D& q& ZEnd Function # E! E3 z! V* b1 O* q6 a7 Y
# K$ L; g8 [) \! U9 W
'可用的返回类型包括 FAT、NTFS 和 CDFS。
: x) I7 U1 ~" v! U6 I- iPublic Function ShowFileSystemType(drvspec)
1 X' l5 c. H: l+ _. ]1 ^Dim d
, Y5 m: ]) K  b5 H& x+ u+ o( b3 oIf ReportDriveStatus(drvspec) = 1 Then
# ?6 o, G1 V% U1 V" R8 {Set d = objFSO.GetDrive(drvspec) 0 J5 V4 B( {# s
ShowFileSystemType = d.FileSystem
$ `, x  a$ D1 u! \( wELse 9 D- X, u+ J4 o; n4 w/ d* @
ShowFileSystemType = -1 1 @/ i9 E% C5 e  f" V- S2 h* h" q
End if 4 Y) e8 m% U/ e- l1 O5 x
End Function
. v  D! J& x+ G  R$ r. o- S* UEnd Class 8 t/ U# m4 f2 s- N1 Z
%>




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