【高州情】高州人深圳站

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

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

管理员

论坛测试[砖]家

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

金币
7319
贡献
615
威望
9151
最后登录
2026-10-4
帖子
1876
积分
25897
UID
10

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

跳转到指定楼层
1楼
发表于 2011-8-17 12:38:09 |只看该作者 |倒序浏览
ASP文件操作大全3 |. K& z; I! m' x: R6 M3 q- b
<% 5 a$ R% F! g+ B+ `, ~0 e" N- c) ^
Class Cls_FSO
7 V* y$ F: y: D3 e% fPublic objFSO
! H6 Q% a# ~4 D; v! N! _* APrivate Sub Class_Initialize()
  J- `- y2 J2 Q2 m& YSet objFSO = Server.CreateObject("Scripting.FileSystemObject")
- z: J7 ~9 L2 ]+ K& aEnd Sub
8 E5 J" p6 e8 c- e) _% R; TPrivate Sub class_terminate() / K- u8 c: _1 v
Set objFSO = Nothing
7 y; t% V* C3 ~. t1 oEnd Sub
7 y$ k, c$ @* z% ^6 B" k- K8 @7 M. m, q
'=======文件操作======== 3 x3 w+ S+ y5 k& |
'取文件大小 . ]- k/ v' s/ g3 W- E
Public Function GetFileSize(FileName)   U2 i- }* g( ~: o% t" j
Dim f , i, O9 J& p; Z  E5 Z! f! j
If ReportFileStatus(FileName) = 1 Then
/ v: c+ \$ e# M  vSet f = objFSO.Getfile(FileName)
: l3 G$ [1 H: `GetFileSize = f.Size
" o0 S5 [! t. x! d6 b+ _1 ?Else $ S) ]7 I3 }# v
GetFileSize = -1 % f6 r; z3 S: G7 {" e' M. O
End if
" J" v- |1 j: }+ ^End Function
6 X! _. v6 Y4 C# J. \+ k
3 `* Z( `7 E5 O& g9 V; Y" m6 w3 `'文件删除
* [$ s# c- H- ~/ APublic Function deleteAFile(FileSpec)
- A' y* c& b; N$ CIf ReportFileStatus(FileSpec) = 1 Then
" j- D' M7 B, @& d% i8 D. VobjFSO.deleteFile(FileSpec)
9 S8 w: i% ^3 o9 G1 fdeleteAFile = 1
' q$ v' w5 Y! u4 \Else 7 V  V8 G1 E: m0 u' i! P
deleteAFile = -1
; w" ?0 u. F1 n0 Q+ X" }End if : A: B6 @2 l0 a
End Function ; k! n! x4 {# L: g. f5 e
. z' r3 y, A/ @9 J3 ^% L+ v
'显示文件列表
5 m* R; T  F9 C" C3 H) MPublic Function ShowFileList(FolderSpec) : n! J" G! C0 l0 A0 M' c
Dim f, f1, fc, s 2 R+ q# m, ?* @: d9 P' R
If ReportFolderStatus(FolderSpec) = 1 Then
0 @8 |$ |( c3 ]6 r' n4 \Set f = objFSO.GetFolder(FolderSpec)
! k# C. ~3 {: oSet fc = f.Files
2 h5 ]" V" p' D% J3 ^For Each f1 in fc . U& i, t4 a3 Z4 I" M
s = s & f1.name 7 P! z9 Q* S  [) H1 D4 G
s = s & "|"
7 n" b) j) D- G% rNext
4 t3 b+ A9 ]8 hShowFileList = s
" b1 m$ ^. {2 w8 ?! ?4 v7 UElse 6 @7 |4 D$ O$ W+ n# R
ShowFileList = -1
, B& E) m: T0 k5 p2 G; VEnd if / Q: \& _5 G6 a% `4 f/ c
End Function - }) Y2 S& F$ B2 d" j; |9 ]
  ~* I+ ^# l$ b
'文件复制 ; V3 T6 g% S  y- V2 W0 G4 u
Public Function CopyAFile(SourceFile, DestinationFile) . U7 \' B2 n- J+ s6 c7 e0 [
Dim MyFile 8 v6 e, e: I% h5 x9 f
If ReportFileStatus(SourceFile) = 1 Then
( R  J1 d+ @1 S- ]: R& u/ j6 D0 VSet MyFile = objFSO.GetFile(SourceFile) : Q% z) K+ s+ P
MyFile.Copy (DestinationFile) 9 }% u3 \' o7 l6 S7 q4 @3 _
CopyAFile = 1 3 ?& f9 D' Q8 G' k
Else   @5 z- ?7 g  i. E8 Z' `6 x2 L4 d
CopyAFile = -1
  V9 g' L7 N+ e0 K$ Y$ xEnd if
1 u" P) X& r8 {  v, P' CEnd Function . x# E! ~( D' S2 K7 w7 N

' m  C, c- t* n  y, l( u6 a'文件移动
2 t1 l! D* e8 X( {% i" t& q, `Public Function MoveAFile(SourceFile,DestinationFile)
4 V& g8 G5 h! S4 _& yIf ReportFileStatus(SourceFile) = 1 And ReportFileStatus(DestinationFileORPath) = -1 Then
. [+ k- R: V+ l% J6 `) t) qobjFSO.MoveFile SourceFile,DestinationFileORPath
9 P* o1 s7 c7 o$ x- h* qMoveAFile = 1 % u7 d) _/ k& h$ K5 \
Else
7 c. n1 ?/ x/ J4 ~MoveAFile = -1
3 L9 ^& W. X- w6 R* [* x$ gEnd if 3 b9 W0 J$ Q% `( m( \
End Function
9 j+ D' x/ X' O' r: }! z( A
) `. O2 t! @; b2 I& s'文件是否存在?
, E; Z' z3 y* a3 l3 GPublic Function ReportFileStatus(FileName) & J  z; i5 Z% m: g: D+ I8 X* F
Dim msg
7 E+ f9 K* K' ]5 U0 b3 b( {msg = -1 8 c' U5 |: ^2 k7 T( I9 [
If (objFSO.FileExists(FileName)) Then
# S- `: u5 N7 wmsg = 1
/ y0 h! M- m& `( j3 G9 nElse
" v. M5 g0 {# }/ T: V* zmsg = -1 7 c: R& }, s% q, p4 o5 w" N
End If
- A! F! C  L, i& L4 O3 A, x# ~ReportFileStatus = msg 1 f" l$ y% W2 [, \6 i" y
End Function 5 Z7 n; r+ N0 N5 _  O0 c9 H

* s* G0 S6 Z$ z' O* v'文件创建日期
1 H$ i. ?, l0 C, g9 HPublic Function ShowDatecreated(FileSpec) * ~; }! x; U" ^
Dim f , u- Z/ E) j; m0 ~) t& p" u8 p8 a
If ReportFileStatus(FileSpec) = 1 Then 4 t+ `( @! P; Y1 X$ t: B5 D
Set f = objFSO.GetFile(FileSpec) # _4 x* F7 i" {
ShowDatecreated = f.Datecreated , K" S# L- A9 m, Y; \, S6 ]" q% M
Else 5 K0 C4 ~+ X. u6 ^4 T! x) V
ShowDatecreated = -1
3 f1 u3 N: a/ z, r  REnd if 5 T2 V/ V1 m; b, [5 x/ v
End Function
3 {: @9 N3 Q- u6 @9 l9 `1 j) d% }, u3 t- ]" V0 Q% r
'文件属性
" i5 g9 {. l( E+ f3 IPublic Function GetAttributes(FileName)
1 R3 T6 V: k5 ^. n; SDim f * M( S5 I$ Q2 i1 b) i
Dim strFileAttributes
' v# t: ?7 f  x" F8 }/ ]! k  CIf ReportFileStatus(FileName) = 1 Then + `, b) ~% x$ o: \* U
Set f = objFSO.GetFile(FileName) 9 X  t  A8 B$ ?* s
select Case f.attributes
7 F# Z; @7 D+ B" v. JCase 0 strFileAttributes = "普通文件。没有设置任何属性。 " 7 `) E( f: m) `" }, J
Case 1 strFileAttributes = "只读文件。可读写。 "
+ ~; w+ ^4 k2 W/ _5 a3 `1 tCase 2 strFileAttributes = "隐藏文件。可读写。 "
( n# }0 C5 [9 \) d$ X( _! sCase 4 strFileAttributes = "系统文件。可读写。 " 9 u, F3 L3 [, U
Case 16 strFileAttributes = "文件夹或目录。只读。 " 5 f$ E& \7 p" s* T" c
Case 32 strFileAttributes = "上次备份后已更改的文件。可读写。 " ' E: Y# `* b+ S# l$ E; [9 w3 [
Case 1024 strFileAttributes = "链接或快捷方式。只读。 "
6 u) R1 [" P7 a" uCase 2048 strFileAttributes = " 压缩文件。只读。"
0 k0 g  e/ H+ Z( Z% k; rEnd select
- w$ g! Q" u( O! rGetAttributes = strFileAttributes
. E$ u# P* b% p1 Z  U! xElse
. e& r9 t/ W! C- s% o- @GetAttributes = -1 ; k& B" l7 x1 t- C/ Y/ Z/ |
End if 6 D' ]% y4 g$ X) O' k0 i
End Function
. o9 P# y: \2 Y
# o. j, ]& _/ D5 X'最后一次访问/最后一次修改时间 ' r9 m/ L( E, W9 M5 |
Public Function ShowFileAccessInfo(FileName,InfoType) : T, D, p" Z% ]. C
'//功能:显示文件创建时信息 4 g6 V4 F- K: P0 M
'//形参:文件名,信息类别
) U9 [* o2 p; [+ U0 t) ^0 D# x'// 1 -----创建时间 / s  |' L4 ]3 I0 q3 A% C# ?
'// 2 -----上次访问时间 7 `7 Y: z& W6 U' l% O1 \, g$ I3 ^
'// 3 -----上次修改时间
: L/ R7 h7 |  A/ }# I) I'// 4 -----文件路径
' B, M* ]' ^( _1 O0 g% e, G7 P' Q$ ?$ x'// 5 -----文件名称
; H6 ]. m% }- k8 c% I6 a'// 6 -----文件类型 8 c) F! l% T* V8 c
'// 7 -----文件大小 4 d( \  R: X( v, s1 n7 ]6 D8 l
'// 8 -----父目录   g" Z, j2 p3 `9 |% ]" F$ u
'// 9 -----根目录 9 w% O/ J& M1 ^- ]7 L6 j+ |9 f& h
Dim f, s
, `' V/ C2 Z0 qIf ReportFileStatus(FileName) = 1 then
5 ?* I8 q) \6 J& N  ]Set f = objFSO.GetFile(FileName)
  \* _# l1 k' \8 T$ q0 t; Hselect Case InfoType $ {% y. b& A" }0 |( h7 L6 {0 f7 L
Case 1 s = f.Datecreated
  F1 S7 |4 @# d5 b$ `9 s$ ?! p, }7 FCase 2 s = f.DateLastAccessed
6 \- h: I  V! zCase 3 s = f.DateLastModified
# o. [+ m8 J8 ~' c: y, m6 wCase 4 s = f.Path
- l+ |% @9 d$ |9 E+ v9 R/ GCase 5 s = f.Name $ l; \  F: C9 [5 m8 x6 D/ F0 \
Case 6 s = f.Type
; d5 P2 N2 z7 @. B2 \: ?Case 7 s = f.Size 2 ~2 ?& ?! J* g. ]0 k  j3 A+ a
Case 8 s = f.ParentFolder
2 Z+ V3 q& u, y/ cCase 9 s = f.RootFolder - ]: D1 F( x1 p  y; q! c& q) F4 T
End select , Q& R* B6 X( b8 ?1 T- C
ShowFileAccessInfo = s
  V7 p- G' X' ^- L. [; S% YELse + B# o) S; E! Y9 \2 ]. _
ShowFileAccessInfo = -1
/ b* P) B8 R" P  ~End if
, U4 `' R( W$ J! KEnd Function 6 l! l8 _2 I1 q+ @
8 w! f. U0 w8 {% W
'写文本文件
9 r* J* M. N# H0 l) gPublic Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
& d, a, B$ l  i7 f! ~5 z6 rConst ForReading = 1, ForWriting = 2 , ForAppending = 8
# ~2 ]( ]9 ~0 D; B0 BDim f, m
# Y6 n6 q/ P; B$ K! }  Pselect Case WriteORAppendType + L0 ]1 V7 U2 J7 r% q
Case 1: '文件进行写操作 ! S$ t3 B( J% {* {8 H
Set f = objFSO.OpenTextFile(FileName, ForWriting, True)
9 b6 v, F1 Z, D$ af.Write TextStr 7 g/ R; x) c3 i8 Z
f.Close
9 T' E' H7 G/ P$ YIf ReportFileStatus(FileName) = 1 then 4 K8 P) \8 l& d" _0 R( u2 X/ J
WriteTxtFile = 1 6 @* G, j* O& N% T
Else
! s, f" h! v$ b) {% l( `WriteTxtFile = -1 1 E7 f( \+ W6 z! B: n4 s
End if
& l, ~, ?" S* }* e; X! I8 HCase 2: '文件末尾进行写操作
6 r7 b) e# {+ R' fIf ReportFileStatus(FileName) = 1 then 9 i2 t% D2 W% ~# b" r; {
Set f = objFSO.OpenTextFile(FileName, ForAppending) 9 c; q3 c( @8 ?  [
f.Write TextStr
0 B4 G. s7 ~  N1 K: vf.Close - o/ R5 V3 s1 T: v6 f5 ?
WriteTxtFile = 1
0 `9 _7 s0 d  j8 pElse
3 r( a7 @9 q1 B# VWriteTxtFile = -1
7 z& @: Y. Q& D4 d; m  ~End if ' N# r: ]7 c5 ~4 f! N7 o
End select
. P. t3 |* e6 O0 j5 TEnd Function
4 l* n- V6 S9 b% ~* ~  ]1 X# X; n7 Y1 Y; m; V
'读文本文件 3 _. z- E5 }/ S3 T+ o: M
Public Function ReadTxtFile(FileName)
0 G1 Q# n- W3 o1 w2 r; T$ _Const ForReading = 1, ForWriting = 2
% \4 B4 R: M$ b2 ~9 w6 {Dim f, m
; W% L* E% ~2 |3 j9 o+ s- H' Z& ?If ReportFileStatus(FileName) = 1 then
" X- a+ }9 B  [- H: L0 j9 gSet f = objFSO.OpenTextFile(FileName, ForReading)
2 \8 e( u' z; N, H: m3 J1 qm = f.ReadLine
$ b$ f4 d* x" d1 m- u4 g, oReadTxtFile = m
, l2 ]' G2 B7 V4 E: Kf.Close
) ^9 q8 J  t) k/ A: T& K: e$ lElse . s2 u# [) Q1 q. v3 j
ReadTxtFile = -1 % A" o: u9 f  m. I/ o% x( _
End if : }  J4 O4 f" A' ]
End Function   @0 J. S7 K2 h

, G2 H4 N. s2 t* O! T'建立文本文件
" {$ D' m6 n# o
7 o3 f' y4 U6 K! }& H'=======目录操作========
" p) J9 [. o. e% K6 Z8 O'取目录大小
) Q8 e7 L4 F7 O0 hPublic Function GetFolderSize(FolderName) ! p; X+ _7 U2 w( e
Dim f 9 A) x& g/ x) s2 O/ U
If ReportFolderStatus(FolderName) = 1 Then
' w: f  k+ b: w( r- OSet f = objFSO.GetFolder(FolderName)
. L& c; f6 t# z6 ?2 z' ~8 iGetFolderSize = f.Size $ i( x! D; Y6 a) ]  |7 O. w( D' B4 Z2 }
Else 3 R' S( d3 `6 E' i9 ?
GetFolderSize = -1
7 i+ T  A- O' O+ gEnd if $ w: `( `: X4 g/ }8 Q: ]0 P
End Function
, T2 W# P; h% z4 A2 E7 Z7 s
2 ^* R/ t* j$ D4 v- d) k2 r, K'创建的文件夹 2 O1 `# W9 b) T; Q% {& @
Public Function createFolderDemo(FolderName)
$ ]& l# p6 K! c2 b3 PDim f + u; r8 p) x8 `8 D1 V
If ReportFolderStatus(Folderspec) = 1 Then
! d; q% h* y. p6 |' I1 {createFolderDemo = -1
7 T9 }* I! C( r- r. \# y- i  `Else 2 Q6 i! x: S! t: ?7 A
Set f = objFSO.createFolder(FolderName) 4 k# G7 M4 G* s. E* X7 a0 \) w! I
createFolderDemo = 1 5 P0 a  f+ E7 b3 c' j3 b  G& @2 P
End if
4 l1 M7 `5 ^# l& }' _End Function
; |( N/ D9 v/ `4 c1 V5 H8 D* }* w! Z! j5 r0 W8 x
'目录删除 ; h, z( d' U* q8 t
Public Function deleteAFolder(Folderspec) * y$ C+ I6 v+ R- c3 i
Response.write Folderspec . x; v- F2 ]3 F
If ReportFolderStatus(Folderspec) = 1 Then # Y% f6 l, }! Z0 \3 s
objFSO.deleteFolder (Folderspec) # y: A$ D: s- i7 P) ~
deleteAFolder = 1
5 c4 M3 Y4 Q' a; ?Else : q! b' Y$ l+ p' N; a& m
deleteAFolder = -1
$ b$ Q6 C  Z8 R3 X: A2 AEnd if
2 u$ v5 l1 Y$ ]% P+ x/ b9 M6 aEnd Function
0 b% l9 t! ~% A
2 ~) R& [% ?2 @$ o/ y'显示目录列表 - r- l+ i. D* _; C; M  I. v
Public Function ShowFolderList(FolderSpec)
+ \. q* q% a4 t; @8 R0 z. l0 oDim f, f1, fc, s
) g5 G/ ~; [8 KIf ReportFolderStatus(FolderSpec) = 1 Then ! F- t& i6 H: ]$ Q9 Z- A+ h
Set f = objFSO.GetFolder(FolderSpec) 6 i: c& X3 f! U  Q; v) o
Set fc = f.SubFolders ' A  V/ Q* ?2 k
For Each f1 in fc
6 ~& ?+ T0 O: ]3 d. C9 [s = s & f1.name
9 P: o2 }  n/ r( v* @# u! b' Ks = s & "|" + ~  W1 v( i1 W  C4 ~
Next " O& f$ z$ }, }) @& P
ShowFolderList = s 3 a8 o9 y; h+ R
Else 9 R. f3 ]8 ~$ h' z" O, J
ShowFolderList = -1 ( _- o4 @% y& K  k& ]# u% Y
End if
8 ^; y$ ]5 c8 k8 o" a" g6 [End Function 3 y5 I4 P/ ~! H! f
4 Y2 z) F$ h) ~  t& L. D
'目录复制
" p5 Y3 u  O7 P& \Public Function CopyAFolder(SourceFolder,DestinationFolder) ; {7 Q  {3 I. g  a% s) ]2 c7 ?
objFSO.CopyFolder SourceFolder,DestinationFolder ' `( j& W/ X. c: c. d$ i$ l
CopyAFolder = 1
* a4 f! n$ ~1 p( V1 GCopyAFolder = -1 * C4 a( g$ v. S, s
End Function : L# |+ ~: l7 c# Z2 m' d0 _  [' M
  n! O4 P7 Q9 `
* Z8 g5 g; k* y# p
'目录进行移动
* F/ I. T) @* \4 [" M6 y, a, TPublic Function MoveAFolder(SourcePath,DestinationPath)
0 y7 F% S" y3 jIf ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0 Then
; x; i7 p3 `+ z& [4 ]objFSO.MoveFolder SourcePath, DestinationPath
6 c& T: A% |% H7 v. y( _MoveAFolder = 1
' N% t5 O+ t6 w& B7 [Else
  u* ?5 f, P, s( x4 B3 n6 x8 BMoveAFolder = -1
, ^# q" i3 x9 C- s" kEnd if - U) R) i8 q6 C  Y2 ~+ ]: [
End Function 6 M1 N7 O5 z' d! @

- |4 g9 C. b: @'判断目录是否存在
" X: z7 L* {7 T1 @% ~Public Function ReportFolderStatus(fldr) 1 v; w& J; X3 G' _  G# N* T
Dim msg ( a  }% j! F/ E) o* O" j0 H9 x
msg = -1 ) E8 j0 R) L. T9 g. G7 o
If (objFSO.FolderExists(fldr)) Then 4 E7 }% K' l; P5 `) c2 J
msg = 1 ( j$ e5 ~* g* M+ t; X) q
Else
9 D" S; c  t& E; o- V9 Y/ mmsg = -1 6 o- ?. E9 T3 [! G7 U
End If % q; o+ r2 N2 s
ReportFolderStatus = msg
, K4 J4 U" t1 j( S% cEnd Function . }  T6 [/ s2 G

2 Q% V! Y3 j& r3 s) L'目录创建时信息 . s; N" y# i0 [& ~
Public Function ShowFolderAccessInfo(FolderName,InfoType) ; s. i/ l$ a  j
'//功能:显示目录创建时信息 0 e" [- k. J2 w( O5 o. [: H
'//形参:目录名,信息类别 $ S  U$ `( L& R8 v
'// 1 -----创建时间 ; f+ d2 x5 D; J+ j, r5 _
'// 2 -----上次访问时间 6 k9 Z1 @4 q) \5 {
'// 3 -----上次修改时间
2 U3 b0 F0 `4 g/ W( {'// 4 -----目录路径 - u% ^6 S3 z) k: d
'// 5 -----目录名称
* ?- O8 n9 `0 L8 f% C4 l/ W'// 6 -----目录类型 4 G& E4 }$ i, ]* }: x: P
'// 7 -----目录大小 5 x. ~9 m9 X7 ?( `# v
'// 8 -----父目录 $ @% z- @1 S  |
'// 9 -----根目录
' @" J6 h1 b7 A3 _3 G! |Dim f, s
3 h" [9 W7 [' RIf ReportFolderStatus(FolderName) = 1 then
- C! Y. N' `6 `1 hSet f = objFSO.GetFolder(FolderName) 1 T* L' \. @) T4 ]4 r. ?
select Case InfoType * X8 w+ m. A9 B3 b! _
Case 1 s = f.Datecreated 7 z- B) y" P' J* d& t. w
Case 2 s = f.DateLastAccessed ( K+ {4 U1 s$ A$ Y
Case 3 s = f.DateLastModified
* `' l# q) P3 H. u# j" \Case 4 s = f.Path ; U7 c( u" i9 N* d- ]( w. [# }
Case 5 s = f.Name
* Q; M+ E4 X% a% v+ o8 ECase 6 s = f.Type
/ p. ^- C' r1 HCase 7 s = f.Size 0 t: `+ F% B& U' l/ t4 f5 a7 i
Case 8 s = f.ParentFolder - F( G! N+ O4 c. M2 s% q
Case 9 s = f.RootFolder
/ b5 X/ j0 [+ m! O6 d# \End select 9 O' C. t" W8 f: Y  V: \
ShowFolderAccessInfo = s
! ^* g$ j8 C! F% V8 L, x& TELse
2 g. D5 r& a. x7 k) A4 qShowFolderAccessInfo = -1 - A% X$ d, Y0 f) |* k* s" J5 I( q
End if
8 o( j, I  |  pEnd Function
+ l8 X- D( N" S+ _1 |
7 M2 y# ^" e; h/ Q'遍历目录 - f* D+ L* `5 L; w9 H
Public Function DisplayLevelDepth(pathspec) . j6 b, K% X' l0 c; B. y9 P8 H0 f1 W
Dim f, n ,Path
* S2 \+ z" x' i! ?' BSet f = objFSO.GetFolder(pathspec) $ R# a8 \4 T' M" a
If f.IsRootFolder Then ' t% k3 q4 R2 u$ U( l
DisplayLevelDepth ="指定的文件夹是根文件夹。"&RootFolder
8 u; W3 O6 V$ t2 x+ I1 DElse
  e, d! p) i2 c( l$ H; W& \Do Until f.IsRootFolder
8 x+ I- P0 T* \& QPath = Path & f.Name &"<br>"
# x+ j5 V( i, u! G  X0 b7 MSet f = f.ParentFolder
2 T5 {( ]5 r7 K* x/ j5 @0 nn = n + 1 % T- ]; A! O/ K8 ^) C( G  R% K; J
Loop * _& g* y4 G- G$ e: w; Y& y( L6 b
DisplayLevelDepth ="指定的文件夹是嵌套级为 " & n & " 的文件夹。<br>" & Path
$ W! Z+ W& H# u6 sEnd If
/ u  k# [# f" K, `* y2 ^+ `' JEnd Function
: H+ n9 Y9 |( C$ V+ t! o8 o# z8 V) K
'========磁盘操作========
5 ?$ ?- C5 h3 u1 n- S! a* n0 N'驱动器是否存在? & @7 ]; w- _0 w+ j7 x* `2 Q& M
Public Function ReportDriveStatus(drv)
# Z! n9 D+ @, d* X/ N3 UDim msg
, L% `* z: ^7 }7 Lmsg = -1
, W/ o0 y8 C" D2 @: b5 rIf objFSO.DriveExists(drv) Then 8 \, r3 l; F* m1 h
msg = 1
: b' g7 v4 v$ E6 @/ A9 G7 @7 }Else " u8 R) G) C% ^0 D4 V1 p) S
msg = -1 6 `1 l7 z; X1 H6 U) _  d* }9 }
End If # E9 G. ^' n& T+ A7 }3 f: m
ReportDriveStatus = msg
1 `" W1 L) t. D# C5 x: D& ?End Function   V. l# m1 S4 Y

. Q* E- u8 Z! n) r'可用的返回类型包括 FAT、NTFS 和 CDFS。 2 j% g0 v) p5 r  a
Public Function ShowFileSystemType(drvspec)
$ F! A; [& N, L9 d$ i# ~Dim d & q/ p$ E9 s! C5 P) q! b
If ReportDriveStatus(drvspec) = 1 Then
. M5 P" Q9 n" C% `Set d = objFSO.GetDrive(drvspec) ; K; B3 E& D, b4 j6 g4 ~3 w
ShowFileSystemType = d.FileSystem
, H2 c+ a' ]0 [) H) H4 MELse 0 K8 }$ x- ^0 T8 D' J5 X
ShowFileSystemType = -1
; s. K3 q6 t0 KEnd if 0 ]. E' c2 @6 v/ |# c
End Function
% D! I& A7 V. ?, HEnd Class
# L- g( P0 Y2 l7 Q; [" P: J%>
这个世界只有10种人:一种是懂2进制的,另一种是不懂的。

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

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

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

GMT+8, 2026-11-7 15:17 , Processed in 0.024019 second(s), 12 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部