正在阅读:VB基础:认识VB的文件系统对象FSOVB基础:认识VB的文件系统对象FSO

2004-03-16 15:14 出处:CSDN 作者:zhangking 责任编辑:linjixiong

  End Function
  '返回布尔值:True 存在,False 不存在,foldername 文件夹
  Function FolderExist(foldername As String)
  Dim Fso As New FileSystemObject
  If Fso.FolderExists(foldername) = True Then
  FolderExist = True
  Else
  FolderExist = False
  End If
  Set Fso = Nothing
  End Function

  3、获取驱动器参数:
  '返回磁盘总空间大小(单位:M),Drive = 盘符 A ,C, D ...
  Function AllSpace(Drive As String)
  Dim Fso As New FileSystemObject, Drv As Drive
 Set Drv = Fso.GetDrive(Drive) '得到 Drv 对象的实例
  If Drv.IsReady Then '如果该驱动器存在(软驱或光驱里有盘片,硬盘存取正常)
  AllSpace = Format(Drv.TotalSize / (2 ^ 20), "0.00") '将字节转换为兆
  Else
  AllSpace = 0
  End If
  Set Fso = Nothing
  Set Drv = Nothing
  End Function
  '返回磁盘可用空间大小(单位:M),Drive = 盘符 A ,C, D ...
  Function FreeSpace(drive)
  Dim Fso As New FileSystemObject, drv As drive
  Set drv = Fso.GetDrive(drive)
  If drv.IsReady Then
  FreeSpace = Format(drv.FreeSpace / (2 ^ 20), "0.00")
  End If
  Set Fso = Nothing
  Set Drv = Nothing
  End Function




察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品