代码改变世界

使用 MakeSureDirectoryPathExists 迅速建立多级目录

2009-12-27 01:08  电脑人生  阅读(268)  评论(0编辑  收藏  举报

Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal strPath As String) As Long

Private Function MakeMultiDirectory(ByVal strNewDirectory As String) As Boolean
    On Error Resume Next
    Dim strPath As String
    strPath = strNewDirectory & IIf(Right(strNewDirectory, 1) = "/", "", "/")
    If MakeSureDirectoryPathExists(strPath) <> 0 Then
       MakeMultiDirectory = True
    End If
End Function