VB FSO自动生成N层目录!
2009-02-22 18:36
253 查看
Public Function SoCPath(DirPath As String) As Boolean
If DirPath = "" Then SoCPath = False: Exit Function
Dim fso As New FileSystemObject
Dim TmpPath, TmpDrive, TmpDirPath As String
Dim TmpArr() As String
Dim I As Integer
If fso.DriveExists(Left(DirPath, 1) & ":") = False Then MsgBox "此计算机并没有" & UCase(Left(DirPath, 1)) & "盘!": SoCPath = False: Exit Function
If fso.Drives(Left(DirPath, 1)).DriveType = CDRom Then MsgBox "此盘符为光驱,请勿选择!": SoCPath = False: Exit Function
TmpDrive = Left(DirPath, 3)
TmpPath = Replace(DirPath, TmpDrive, "")
If Right(TmpPath, 1) = "/" Then TmpPath = Left(TmpPath, Len(TmpPath) - 1)
TmpArr = Split(TmpPath, "/")
For I = 0 To UBound(TmpArr)
If I = 0 Then TmpDirPath = TmpDrive & TmpArr(I) Else TmpDirPath = TmpDirPath & "/" & TmpArr(I)
If fso.FolderExists(TmpDirPath) = False Then MkDir TmpDirPath
Next
SoCPath = True
End Function
If DirPath = "" Then SoCPath = False: Exit Function
Dim fso As New FileSystemObject
Dim TmpPath, TmpDrive, TmpDirPath As String
Dim TmpArr() As String
Dim I As Integer
If fso.DriveExists(Left(DirPath, 1) & ":") = False Then MsgBox "此计算机并没有" & UCase(Left(DirPath, 1)) & "盘!": SoCPath = False: Exit Function
If fso.Drives(Left(DirPath, 1)).DriveType = CDRom Then MsgBox "此盘符为光驱,请勿选择!": SoCPath = False: Exit Function
TmpDrive = Left(DirPath, 3)
TmpPath = Replace(DirPath, TmpDrive, "")
If Right(TmpPath, 1) = "/" Then TmpPath = Left(TmpPath, Len(TmpPath) - 1)
TmpArr = Split(TmpPath, "/")
For I = 0 To UBound(TmpArr)
If I = 0 Then TmpDirPath = TmpDrive & TmpArr(I) Else TmpDirPath = TmpDirPath & "/" & TmpArr(I)
If fso.FolderExists(TmpDirPath) = False Then MkDir TmpDirPath
Next
SoCPath = True
End Function
相关文章推荐
- 自动检测创建多级目录, fso与stream生成文件函数
- 论文格式设置-页面设置、页眉页脚、自动生成目录等
- word自动生成目录--小写字母变大写
- Thinkphp 项目目录不可写,目录无法自动生成
- thinkphp之自动生成目录安全文件
- 2017.5.3 博客园自动生成章节目录
- 毕业论文中的“自动生成目录”设置(经验四)
- vs生成的文件如何自动拷贝到指定目录
- Maven利用Archetype自动生成项目目录结构
- winform程序在编译时,如何自动将文件生成到debug目录下?
- Word2010 自动生成目录
- word中自动生成目录和图表目录
- sublime text3 + OmniMarkupPreviewer + js 自动生成跳转导航目录
- 论文自动生成目录和参考文献上标的一些小技巧【转】
- 自定义博客园,个性导航二级下拉菜单,访客统计,侧边栏分享,文章目录自动生成,全局/文章返回顶部
- Thinkphp5.0实战开发二------自动生成目录结构
- Jquery实现自动生成二级目录
- Thinkphp5.0自动生成模块及目录的方法详解
- 使用Python生成博客目录并自动更新README
- Thinkphp5.0实战开发------自动生成目录结构