人的头脑太复杂,时间过得久,有时候连自己也被自己骗了,记下来才是最真实的..
2006年9月27日 20:05
Function AutoCreateFolder(strPath) ' As Boolean
 On Error Resume Next

 Dim astrPath, ulngPath, i, strTmpPath
 Dim objFSO

 If InStr(strPath, "\") <=0 or InStr(strPath, ":") <= 0 Then
 AutoCreateFolder = False
 Exit Function
 End If
 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 If objFSO.FolderExists(strPath) Then
 AutoCreateFolder = True
 Exit Function
 End If
 astrPath = Split(strPath, "\")
 ulngPath = UBound(astrPath)
 strTmpPath = ""
 For i = 0 To ulngPath
 strTmpPath = strTmpPath & astrPath(i) & "\"
 If Not objFSO.FolderExists(strTmpPath) Then
 ' 创建
 objFSO.CreateFolder(strTmpPath)
 End If
 Next
 Set objFSO = Nothing
 If Err = 0 Then
 AutoCreateFolder = True
 Else
 AutoCreateFolder = False
 End If
End Function
 


调用方法:


MyPath = "C:\a\b\c\"
If AutoCreateFolder(MyPath) Then
 Response.Write "创建文件夹成功"
Else
 Response.Write "创建文件夹失败"
End If
我要 [保存此页] [收藏此页] [复制此链接QQ/Msn发送]
收藏到 [天天] [和讯] [我摘] [天极] [新浪] [博采] [Del.icio.us]
我们推荐您 快去试试吧!
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]