【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

金币
7316
贡献
615
威望
9151
最后登录
2026-8-24
帖子
1875
积分
25896
UID
10

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

跳转到指定楼层
1
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全
# g) s& T' u) e<% " Q$ t4 C$ G+ ]9 z- I
Class Cls_FSO 2 F4 c  `# u( \0 [. \
Public objFSO
  ~- Z! q" O& \Private Sub Class_Initialize()
8 B' M4 H4 q0 y0 o8 ]9 u" |Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ! T0 Q% [/ W4 ]. i$ x) |
End Sub
2 B0 s/ Q! i" d7 nPrivate Sub class_terminate() * X; n4 G- E+ z/ L  F7 P( q/ l, s6 v
Set objFSO = Nothing 0 Y$ v. ^) Y" v+ w2 U( Y- _
End Sub
* g5 k1 t0 h3 Z; f  e% W' w7 }$ C
! E( i1 C- B0 E9 T'=======文件操作========
, t( b6 u8 z  e'取文件大小
  J6 f# ^' X* iPublic Function GetFileSize(FileName)
. \( o: x+ x) X8 xDim f
+ b! N! u6 f3 A. k* A; u1 i! JIf ReportFileStatus(FileName) = 1 Then : R9 O* z# m6 U# s- v
Set f = objFSO.Getfile(FileName) + K* J& H) P% {1 t# X. l
GetFileSize = f.Size
6 r' Y& I  J" _Else
% q6 x! R8 _' ]GetFileSize = -1 6 F+ G; T; g. Z! J
End if
; l  [, |  ]6 P+ T6 ?End Function
# [  G4 f% _! Y/ l" @
0 O; O6 O& _* J) X% J0 o% x'文件删除 / l1 |5 y7 R, K  v9 T! O7 {. L
Public Function deleteAFile(FileSpec)
+ @* p' F+ B  a4 AIf ReportFileStatus(FileSpec) = 1 Then
- D; k. b4 V+ ~4 ]* yobjFSO.deleteFile(FileSpec) 7 g& x0 z$ p1 Y) g1 C6 ~2 v
deleteAFile = 1 ( _/ t% ?" l) c; R: K- C% h& ?% b
Else : y! m: ]: R* O
deleteAFile = -1 ' h$ t) @( f- o  U+ J6 V4 k
End if
# U8 O& a& O0 sEnd Function
, a) d+ A" u- K! N, b
. c" Q" c- z3 ^. N5 R" H' D'显示文件列表 5 N% [' B0 [8 `" a; @5 e
Public Function ShowFileList(FolderSpec) 3 k5 f7 J! Q# Z# J( W- s% G! k
Dim f, f1, fc, s $ R* w& W( d! J9 T
If ReportFolderStatus(FolderSpec) = 1 Then
$ s6 [9 P* n  w& e0 l9 P- [/ OSet f = objFSO.GetFolder(FolderSpec)
7 D6 Y6 i- ^5 N8 m' a0 LSet fc = f.Files
) y/ N( U6 T' X, W# i+ w3 GFor Each f1 in fc
$ S, @) t8 E0 P) ^+ L7 ]+ l0 Fs = s & f1.name 4 |4 `* V8 P5 K/ K# z0 `7 q2 {, x6 f
s = s & "|" ; z* X" m4 L. M! V% g5 L
Next 9 q8 t1 p& s" K1 G! l0 G! ^  _
ShowFileList = s
: F% l  B% D4 l, j8 n- vElse
1 z; T4 }* M! `ShowFileList = -1
: G6 F0 c" I, V8 K. XEnd if % X% U3 g$ q( N
End Function / R" U. [; E) M2 g5 ?& L

2 {1 |& ?4 Z$ Z7 [! c'文件复制
# i9 X* Q* A$ r* i1 i, NPublic Function CopyAFile(SourceFile, DestinationFile)
' Y7 w+ p; d, z, @Dim MyFile ! q& I) Z0 G; I7 P% d
If ReportFileStatus(SourceFile) = 1 Then ) z3 u- \$ V" p8 l. G4 Q
Set MyFile = objFSO.GetFile(SourceFile)
$ @3 c% L, v8 q/ v" iMyFile.Copy (DestinationFile) " b9 Y1 `3 [6 v6 k
CopyAFile = 1
# B/ r7 n: I# p' ]1 z4 J. hElse
0 m7 }( o) j* c6 eCopyAFile = -1 8 ^8 W) k& q7 t
End if , k( L! Z& C( [) h$ S; L: e7 x4 A
End Function / l' k& y0 M/ ~+ [$ z4 J
+ J; X) D5 }  j- v% j' B7 E3 W! r
'文件移动 ) S% Y2 z! j# y/ I1 n* P- X+ o% O
Public Function MoveAFile(SourceFile,DestinationFile) 1 A. H4 s' y' E( c+ b$ R
If ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
. w) N0 d' ~8 e; S9 Z) j5 [  [. |objFSO.MoveFile SourceFile,DestinationFileORPath
. M- F$ L1 G0 a5 ^5 x: ]MoveAFile = 1 / a7 N: x! n% v* s! b2 o
Else " |# H) ?, Z% o2 \
MoveAFile = -1 # o- s6 {/ b8 k9 X* }
End if
, z# _: Z5 o5 xEnd Function 0 i( J3 ?$ Q3 v6 N( ~) U- `
* F$ ?0 I/ T% c" m, ~
'文件是否存在?
) s) [% a, _; T8 m  Q4 JPublic Function ReportFileStatus(FileName) 4 N0 a/ I6 s  j8 C# x( ]: R% i
Dim msg " k+ n2 E5 O- I- a5 h! p
msg = -1 2 l: u+ K: Z- P8 S8 f
If (objFSO.FileExists(FileName)) Then
9 Q9 K, g- L% wmsg = 1 - `8 I2 ^/ s# ^9 N2 C/ B
Else 1 e8 A' t3 F5 S5 m( h. h
msg = -1
7 W2 p" k8 a! R+ WEnd If , ^- F0 p0 G8 E2 x. q( Y
ReportFileStatus = msg
, J% y' t' I/ ~! k6 K' B0 kEnd Function , c1 d: V" w; w/ s2 |
8 T. ?. V; j. ^, N
'文件创建日期 ) Q2 l, {6 }) c2 n- h) h" v, Z+ ]
Public Function ShowDatecreated(FileSpec)
/ f' m: c! M7 u& J( L1 G1 B- f& P1 i' xDim f
% I; i8 a' m3 e$ l0 O+ l. z' {If ReportFileStatus(FileSpec) = 1 Then " c+ t4 F; w- d
Set f = objFSO.GetFile(FileSpec) & L( t( `% {, H
ShowDatecreated = f.Datecreated
7 \/ y0 f$ H7 U; tElse 5 F2 h6 S) u% A2 y3 [8 ]
ShowDatecreated = -1 3 \" t' H7 S5 Y% V! y
End if 4 S7 o7 @+ {7 e9 j
End Function % X0 w9 Y7 _2 u! a% x" s

' L' `% L; [+ y& U% N'文件属性
4 X3 Y+ S" ?$ yPublic Function GetAttributes(FileName) * T- h4 v1 Y+ M% n' q6 |
Dim f * ]+ c2 `# ?6 |+ o9 x2 Y& x" R; |
Dim strFileAttributes ; p$ ?3 L& v/ r  `) n; Q) Q
If ReportFileStatus(FileName) = 1 Then 5 W$ w. h! d# B) v
Set f = objFSO.GetFile(FileName)
6 ]8 W7 n3 O; d" G- ?select Case f.attributes % E: N4 _; W9 n8 [- d
Case 0 strFileAttributes = "普通文件。没有设置任何属性。 " 8 i3 c  V4 k3 a+ M) _+ \
Case 1 strFileAttributes = "只读文件。可读写。 "
8 e4 M! I/ f# sCase 2 strFileAttributes = "隐藏文件。可读写。 " ' P; j; U. ?/ J3 x* E, O6 F
Case 4 strFileAttributes = "系统文件。可读写。 "
* o0 c+ Z7 n, D6 J: MCase 16 strFileAttributes = "文件夹或目录。只读。 "
# Y* s3 g, n# j4 T% d' ^Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 "
& a( H1 T! E" V1 h( Y0 mCase 1024 strFileAttributes = "链接或快捷方式。只读。 "
) u+ {2 v  u8 }5 [Case 2048 strFileAttributes = " 压缩文件。只读。" ! G2 i* v& k# j- c% a2 _2 I1 t
End select
: d+ v" [, Y. W& x+ _GetAttributes = strFileAttributes " [* W% ~/ d, r' w
Else
' J, m1 @2 V2 K$ P! y$ w$ WGetAttributes = -1
6 f- m! G  Y+ }% K6 KEnd if . Y7 l6 V: Y! q6 |
End Function $ l) y4 {. G: s1 q; A, u- P4 J

5 u: A6 ~, y: n5 h" }& [% V'最后一次访问/最后一次修改时间 ! `8 `  c& P  A$ u; M
Public Function ShowFileAccessInfo(FileName,InfoType) + l" f6 l/ t: u- M
'//功能:显示文件创建时信息 2 S* I0 w2 u0 R. w8 [  j
'//形参:文件名,信息类别
* t+ \4 K% e: \- R8 Q* k8 M7 y'// 1 -----创建时间 9 W- R9 ?  J7 j  z
'// 2 -----上次访问时间 8 }- n" X1 e/ v$ O+ N: N  d
'// 3 -----上次修改时间
# M' p1 H" Q& y1 l* y. ?* `8 U'// 4 -----文件路径 6 a2 A7 a' v% D/ X
'// 5 -----文件名称
; K9 z6 K/ t- A/ f'// 6 -----文件类型
) p; |) f0 w% {'// 7 -----文件大小
& I+ K( R/ q. ]'// 8 -----父目录
* z( Y& A9 H7 H) F'// 9 -----根目录   I/ e# Z3 O* P& M( M
Dim f, s
* M0 u5 `+ B+ kIf ReportFileStatus(FileName) = 1 then
/ G1 ]/ |. o1 D1 s. }! wSet f = objFSO.GetFile(FileName) 7 }: F' u. H, T$ K
select Case InfoType + w  J+ O4 k2 J9 w: C9 D( l
Case 1 s = f.Datecreated
3 B/ N; |8 l- kCase 2 s = f.DateLastAccessed
: c; P. K8 w& K) R7 l6 UCase 3 s = f.DateLastModified
4 ]. E. [+ l  F& fCase 4 s = f.Path
" Q. d# j% c" LCase 5 s = f.Name
" @3 H8 f. h; K2 @Case 6 s = f.Type # v; T4 O' @( }+ d
Case 7 s = f.Size
' N4 X2 C7 G% v; K8 r6 ], \& V$ KCase 8 s = f.ParentFolder & C0 Q) n1 r$ q; v
Case 9 s = f.RootFolder ' p% O! f' v6 O, B" x. A8 }1 [0 q1 L; B
End select
* C4 a( j5 H9 y( j5 nShowFileAccessInfo = s
# b" Z( v0 B" E0 [- LELse
- h& G3 Q  |! F3 z% P! q  sShowFileAccessInfo = -1 % B7 x/ j) R6 T- Q/ p; I/ g
End if
7 F3 I5 O7 w& C, m% h6 [6 XEnd Function
' z/ h+ C5 p  y0 [, _# n6 }" B% z8 B2 ]2 [# h
'写文本文件 & a1 T9 H( Q  A, }! t  K
Public Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
' A) C; R! v! _Const ForReading = 1, ForWriting = 2 , ForAppending = 8 4 H5 w2 c$ l# t  o/ f& P
Dim f, m , g! @" K8 j: l$ q1 C
select Case WriteORAppendType
5 B$ Y' x5 ~4 N3 C9 q4 ^& C6 qCase 1: '文件进行写操作 ! q4 q# U5 ~2 K* K6 Z4 k, G6 }
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
% ^3 i4 l2 u  {; r- l' r  Lf.Write TextStr 6 |: @# t$ k: T9 _3 K) s
f.Close ; [+ }8 U7 {8 |# v! v: ~! h5 w
If ReportFileStatus(FileName) = 1 then - d) J* U! p0 c$ }% C
WriteTxtFile = 1
# f& n' e+ ^4 E+ m$ y+ R' nElse ; D& \- A3 M) |% F$ @2 t/ i
WriteTxtFile = -1 % `! p6 S& E( r3 E& }( n3 V5 n+ {
End if
7 o8 z' a) }! bCase 2: '文件末尾进行写操作
. o) ]) t' m; D1 B) b- {. r8 qIf ReportFileStatus(FileName) = 1 then ' O. x! ~9 d; i( Y$ R8 {; w) [5 k
Set f = objFSO.OpenTextFile(FileName, ForAppending)
. G, Q9 e# T8 H7 N+ gf.Write TextStr
* [& y$ W/ T9 H8 s' Z: Q3 nf.Close
# N- D/ r- T6 j$ ?  p/ TWriteTxtFile = 1 . w" B% n+ u4 ~/ s9 o0 l9 H$ l
Else
/ E2 z3 W$ F+ p# g8 _' tWriteTxtFile = -1
% `) P' J: i3 d5 u7 a8 sEnd if
9 B% V3 ~* V& K3 zEnd select 5 Z4 B/ b7 `  }" `" n* \
End Function ; s, o7 i" b  {2 I/ L+ c1 c1 d

; y: ]4 O: m9 @* p9 l! A' f'读文本文件
# G8 I: Y# ]6 g4 y2 A1 y6 HPublic Function ReadTxtFile(FileName)
# Y& w. m9 D8 ~4 E- s  vConst ForReading = 1, ForWriting = 2 7 B+ D2 P7 F8 J5 k  y
Dim f, m ! M# ?- E: b' x: R( e5 c7 z9 @( N
If ReportFileStatus(FileName) = 1 then
$ J& u! f" v$ H! CSet f = objFSO.OpenTextFile(FileName, ForReading)
; ], U5 E* H) pm = f.ReadLine ) g# Z9 W% a, R% e7 G
ReadTxtFile = m 0 e! A( Q6 q2 k4 }6 X2 m- P
f.Close - u. l- ~* j) J( F# `
Else
& n, R5 ~* L3 Z' f$ PReadTxtFile = -1
6 N" |/ q' E# EEnd if
: i8 K5 S" t2 [+ b2 oEnd Function
7 j# d# ^0 O) J$ {6 s
3 m% t8 d3 f, y: i% o0 v'建立文本文件
5 Q4 D5 @0 ^! Q
+ X% m% R* h. L  \' e: p. l% o% b'=======目录操作======== & a4 q: Z7 u" _1 B6 @
'取目录大小
' {: ~* I+ L! L9 t! J% XPublic Function GetFolderSize(FolderName) ! G/ _0 T# n' n( Y- f
Dim f ( f& w1 [/ ~2 [. `9 k
If ReportFolderStatus(FolderName) = 1 Then 0 K* _$ i- \0 a/ p8 ]9 [
Set f = objFSO.GetFolder(FolderName) 5 o' i; F" P$ o
GetFolderSize = f.Size ) M% n+ [" E5 N5 y  B( x# j4 o
Else 1 I2 E0 J! ~" i
GetFolderSize = -1 + ]8 U# E, L2 F& h
End if
* f7 G& {6 Q* pEnd Function 7 Y' e! g  _" G6 a: B; y/ e

9 A' A9 I6 q+ H2 r6 ?'创建的文件夹 * `& T3 m9 S* p/ X( U2 P
Public Function createFolderDemo(FolderName) ) J+ M3 p! C# N- C% z- X0 U
Dim f 9 e& G" D1 Q4 n, t
If ReportFolderStatus(Folderspec) = 1 Then
+ U( f; q' [5 x' c, ScreateFolderDemo = -1
) [6 u8 h: q# q+ mElse
! ?! p1 S: d! C: }' N; zSet f = objFSO.createFolder(FolderName) % [% [6 q* B  w4 M  P8 o
createFolderDemo = 1 4 y8 Y+ r  y, p. r  X* p+ A
End if + A6 h, N5 W( t7 O& M
End Function / Y5 x+ H2 w; Y3 y: `
5 k5 w8 U' O- B, Q& E( G4 U- O
'目录删除
$ n9 V0 |3 c; G* Y2 ]7 oPublic Function deleteAFolder(Folderspec) 7 q" S! m8 ~, u  w4 O
Response.write Folderspec & x" ~  V7 I3 ^( K$ Q2 f
If ReportFolderStatus(Folderspec) = 1 Then ( N+ F7 R$ R7 w# o
objFSO.deleteFolder (Folderspec)
( j" l  d' y2 T! s" f2 p* |2 N9 ], ]deleteAFolder = 1
0 D1 O% @* k0 CElse
0 b) I9 U' h0 H/ \/ l) P& IdeleteAFolder = -1
% Z- w! W& o/ Y( ?End if ) |8 C* K1 P+ t  B# ~7 {( o3 b
End Function 8 `* C4 g* w$ `" q1 j) ]

; \! V, H; J" G% C8 J'显示目录列表 ) `0 T, t; N5 b$ c, W
Public Function ShowFolderList(FolderSpec)
" L+ g2 }. `! [Dim f, f1, fc, s $ y# y' [: s+ Q& Y- c8 b$ t
If ReportFolderStatus(FolderSpec) = 1 Then - A7 @9 w! b0 l$ O5 z
Set f = objFSO.GetFolder(FolderSpec) 0 I9 ~& \, [$ d: t: m/ Z
Set fc = f.SubFolders
( Q9 p1 F( J+ x! R+ lFor Each f1 in fc
7 Z9 G, c9 C, E: l4 Ds = s & f1.name
7 B: P1 U  U$ e; p7 o: xs = s & "|" % r- r2 Y. \& W1 Q3 m, G
Next
, M. a% v8 s  e9 d- \ShowFolderList = s
7 b' c5 N/ K: v) UElse   k) C7 u& S. Z+ p& s8 S, F
ShowFolderList = -1
% Z$ r8 u- T( o! C  f' N' F( o' E* [End if
* w5 X9 z& L8 N: Y  gEnd Function
. f+ e' y8 a" b) c4 S9 S/ }& b1 r. b6 [4 ~/ c( N1 r9 v
'目录复制
8 S1 U2 _6 L" i- tPublic Function CopyAFolder(SourceFolder,DestinationFolder) 5 V/ u' t1 J3 J3 u, ]* ]1 c. j
objFSO.CopyFolder SourceFolder,DestinationFolder
3 G) ?4 h! n6 j6 y3 R$ {CopyAFolder = 1
5 {) {5 _$ w7 k) U' y7 P/ @; kCopyAFolder = -1 # I3 I  t3 v: c, b0 J/ ]9 X
End Function
1 r/ E5 v% Z/ {8 c, z3 W. y
; S/ S6 t: j0 X3 R4 r5 S5 ?- s% k7 _$ [5 Z6 d1 W) m" v* e
'目录进行移动   C5 N, a# e) N; L" Y2 h
Public Function MoveAFolder(SourcePath,DestinationPath) / @+ [" F  T9 O' W: I! }/ X: S1 s8 q9 D
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
2 p7 z5 o" u& P/ W2 m; `2 ?objFSO.MoveFolder SourcePath, DestinationPath # ?) f) W6 e5 A( {# t% e
MoveAFolder = 1 6 Z" o* {  R# e: L# \
Else
5 A6 o# _1 D8 w$ \MoveAFolder = -1
  p5 \4 [" W+ u% J+ G4 mEnd if $ }& G. k" k( ?$ b
End Function 4 k1 M" Y; m& D  T5 A) K; m

+ V0 s5 ^6 O- b" D  T2 ]7 o& L'判断目录是否存在
$ V4 b7 }* q! t9 I% A. u' BPublic Function ReportFolderStatus(fldr) 4 `6 v& A% N. g
Dim msg , R4 L  g0 }6 t6 k
msg = -1 2 X' p; z3 M! g: w0 }$ h/ f% }8 [( w
If (objFSO.FolderExists(fldr)) Then , X8 ?7 _2 Z6 D; Z; y
msg = 1
7 c# u, s  Z* a7 A, @& j! eElse
5 q1 _- R' O9 ]& n/ jmsg = -1 2 ^" }6 m: Q/ j* L. ^
End If
. r7 U5 j  \! q7 A2 RReportFolderStatus = msg - v, s, N; ~1 c8 ^. `& `6 c
End Function : O4 M: x) o( M. r7 e

- k; ]+ m. d( p* u% F- t  m7 l' a'目录创建时信息 1 Q( E- W% B% t1 s$ a8 r
Public Function ShowFolderAccessInfo(FolderName,InfoType)
% r& @. `0 l7 a9 T9 P0 J0 g'//功能:显示目录创建时信息 5 d* N. t8 T0 Z
'//形参:目录名,信息类别
7 D3 C5 ^5 r% S( H7 f  W'// 1 -----创建时间
0 D2 \! ^# }0 X! [8 S7 w'// 2 -----上次访问时间
9 M/ g$ z4 O2 _( y/ G3 n'// 3 -----上次修改时间
8 z0 s. X, w) X'// 4 -----目录路径   u6 ?$ M/ h& S& Y
'// 5 -----目录名称
6 v: r3 k* S$ o+ @'// 6 -----目录类型
9 t# X2 f* ~8 o& \( Q6 x1 \4 @6 ?'// 7 -----目录大小 # {+ }% H* }& Y
'// 8 -----父目录 ; M$ A4 b% [" k9 N
'// 9 -----根目录 # W% ^! a) |) q/ [; K) o/ X# Y
Dim f, s
0 H/ |1 i& H; K4 l# O' OIf ReportFolderStatus(FolderName) = 1 then $ ^; K; k: P! X: _. P) K
Set f = objFSO.GetFolder(FolderName)
+ t9 E7 E; Y# @4 Q3 ]" oselect Case InfoType
/ k0 O; @% d" X) c; S" N: `4 uCase 1 s = f.Datecreated . u; g* e2 p3 M
Case 2 s = f.DateLastAccessed 6 i9 G8 S& M" @8 P( V% @2 M
Case 3 s = f.DateLastModified
5 G2 }  G0 s; J/ G  G9 RCase 4 s = f.Path & ~& D* ~! ]% I' d4 }$ c
Case 5 s = f.Name ! G2 X$ ?+ n5 \  r& K
Case 6 s = f.Type
, H. U1 \$ \: p/ o9 E2 dCase 7 s = f.Size
$ }! i$ R  h6 @7 _; r+ V+ gCase 8 s = f.ParentFolder
. y; @1 @3 x7 VCase 9 s = f.RootFolder
# H% B( u4 {: N: XEnd select 5 Z( |0 M' t+ ^0 f
ShowFolderAccessInfo = s : b1 B8 E) w. j1 [8 w0 {
ELse / W3 |7 K( K$ o
ShowFolderAccessInfo = -1 : F( l2 n4 C1 ~
End if
7 o5 u; `" c7 n; T1 aEnd Function
# G# _, z+ i. z
7 v5 s4 Z; M$ w8 C* H'遍历目录 : D; A% `& j* c' }
Public Function DisplayLevelDepth(pathspec) 7 e% |6 J: u4 l
Dim f, n ,Path # e5 a- M8 n# o0 \; {: @
Set f = objFSO.GetFolder(pathspec)
6 ]5 x, R$ b1 A" H; w5 R& YIf f.IsRootFolder Then ( X; J. x* V! J# o6 W  r+ i/ V5 j! e
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder : n8 Y% w! c& E% \4 L& E
Else 9 I7 s2 x: u; a# ~
Do Until f.IsRootFolder
( j) b2 I5 u2 K9 _# _( qPath = Path & f.Name &"<br>"
" S4 h  l! i& t/ d* ~! NSet f = f.ParentFolder 4 h, Q* m5 k. `& e( p  ~3 D0 G
n = n + 1
* h) B5 D3 B2 R$ J; X/ o  v/ pLoop . m% N$ P  `. j9 U$ O: Q+ E2 g1 l
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path + L& w# O/ ^! W6 b4 K
End If 6 H& {! I1 j. f) |( ?
End Function
1 Y2 }9 N+ V  Y  ^  j/ s
' q- {. H! g0 m: L: m" y+ w, j- \* w'========磁盘操作======== & g& f3 |/ X+ r7 V* m$ N7 |) H
'驱动器是否存在?
" v& d: R3 a# W+ l& u, hPublic Function ReportDriveStatus(drv)
3 F6 c! |6 \; `+ ]Dim msg 2 d( l6 H, B- M& P* u0 j
msg = -1 ! H3 n2 d: p' g8 ^/ L
If objFSO.DriveExists(drv) Then
* L% N/ W3 V2 J7 X5 ?- e7 v+ Q5 c* L! emsg = 1 5 m# O" V+ B; L7 g8 P- R* S0 f
Else # R4 X8 j" b2 z# t7 q6 x' p6 L
msg = -1
+ R& D3 \) n6 C6 o# Z1 |1 O4 \End If
0 `( u4 t% y; p: L. b/ G$ y* JReportDriveStatus = msg
8 @* N! s1 e% J5 ?4 r- S' oEnd Function ! W: ^1 a) ]1 N

7 Z% `8 i1 T' m'可用的返回类型包括 FAT、NTFS 和 CDFS。 7 R# p' Z' X4 p- d# C
Public Function ShowFileSystemType(drvspec)
  b) @6 C, d9 FDim d % K. U- h. W& r7 D
If ReportDriveStatus(drvspec) = 1 Then
, i( c* P& u! @; DSet d = objFSO.GetDrive(drvspec)
; W' I: k3 f. ?% U: P2 a/ UShowFileSystemType = d.FileSystem
' ~" R  {# n. p2 w% |: O; AELse
* q  ~) B5 S6 E. p4 T5 oShowFileSystemType = -1 ' h! \# f# D! k0 \, N9 M$ D" m
End if 4 O1 P  I* C* g5 t# M  q/ c
End Function
5 \3 n, x9 h$ x2 a1 R& xEnd Class
) @- r# l+ i6 [; s. P%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

GMT+8, 2026-9-23 07:19 , Processed in 0.023164 second(s), 13 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部