注:CheckPath 函数
function checkpath(byval sPath as string) as string
if right$(spath,1)="\" then
checkpath=spath
else
checkpath=spath & "\"
end if
end function
'创建指定的目录(可以是多级目录)
Private Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long
'创建指定的目录(可以是多级目录)
'日期:2002-6-18
Public Function CreateDirectory(ByVal sDirectory As String) As Boolean
'sDirectory:要创建的文件夹
On Error GoTo ErrHandle
Dim lngResult As Long
sDirectory = CheckPath(sDirectory)
lngResult = MakeSureDirectoryPathExists(sDirectory)
CreateDirectory = IIf(lngResult = 0, False, True)
ErrHandle:
If Err <> 0 Then
CreateDirectory = False
End If
End Function
Private Sub Create_Folder()
Dim fso As New FileSystemObject, fldr As Folder
Set fldr = fso.CreateFolder("C:\MyTest")
MsgBox "Created folder: " & fldr.Name
End Sub
Private Sub Create_Folder()
Dim fso As New FileSystemObject, fldr As Folder
Set fldr = fso.CreateFolder("C:\MyTest")
MsgBox "Created folder: " & fldr.Name
End Sub