'获取驱动器文件系统类型,Drive = 盘符 A ,C, D ... Function FsType(Drive As String) Dim Fso As New FileSystemObject, Drv As Drive Set Drv = Fso.GetDrive(Drive) If Drv.IsReady Then FsType = Drv.FileSystem Else FsType = "" End If Set Fso = Nothing Set Drv = Nothing End Function 4,获取系统文件夹路径: '返回 Windows 文件夹路径 Function GetWindir() Dim Fso As New FileSystemObject GetWindir = Fso.GetSpecialFolder(WindowsFolder) Set Fso = Nothing End Function '返回 Windows\System 文件夹路径 Function GetWinSysdir() Dim Fso As New FileSystemObject GetWinSysdir = Fso.GetSpecialFolder(SystemFolder) Set Fso = Nothing End Function 5,综合运用:一个文件备份通用过程: 'Filename = 文件名,Drive = 驱动器,Folder = 文件夹(一层) Sub BackupFile(Filename As String, Drive As String, Folder As String) Dim Fso As New FileSystemObject '创建 FSO 对象实例 Dim Dest_path As String, Counter As Long Counter = 0 Do While Counter < 6 '如果驱动器没准备好,继续检测。共检测 6 秒 Counter = Counter + 1 Call Waitfor(1) '间隔 1 秒 |
正在阅读:VB基础:认识VB的文件系统对象FSOVB基础:认识VB的文件系统对象FSO
2004-03-16 15:14
出处:CSDN
责任编辑:linjixiong
键盘也能翻页,试试“← →”键