VB创建多级目录

'========================================================================= '创建日期: 2011-06-17,hellostory '函数说明: 创建多级目录 '参数说明: 多级目录的路径名 '========================================================================= Public Function createMultiLevelFolder(path As String) As Boolean On Error GoTo errHandler Dim index As Integer, tempPath As String createMultiLevelFolder = False If Len(Trim(path)) = 0 Then Exit Function End If index = InStr(1, path, "/") Do While index > 0 tempPath = Left(path, index) '这里index(“/”所在的位置)可视为要截取的字符长度 If tempPath = "//" Then '对“//”后面的主机名或IP不处理 index = InStr(index + 1, path, "/") Else If Dir(tempPath, vbDirectory) = "" Then MkDir tempPath End If End If index = InStr(index + 1, path, "/") '返回下一个“/”的位置 Loop createMultiLevelFolder = True errHandler: If Err.Number Then MsgBox "创建多级目录(" & path & ")时出错:" & Err.Description, vbInformation, "错误" createMultiLevelFolder = False Resume Next End If End Function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值