Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7333911
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68080
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 14:20:20

下载本文示例代码

开启FSO权限 在 开始-“运行”中执行regsvr32.exe scrrun.dll即可。如想关闭FSO权限,在上述命令中加/u参数。注册表中的键值位置:HKEY_CLASS_BOOT\F.S.O .FSO中有个方法是CreateFolder,但是这个方法只能在其上一级文件夹存在的情况下创建新的文件夹,所以我就写了一个自动创建多级文件夹的函数,在生成静态页面等方面使用非常方便。函数:

以下为引用的内容:
’ --------------------------------
’ 自动创建指定的多级文件夹
’ strPath为绝对路径
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

开启FSO权限 在 开始-“运行”中执行regsvr32.exe scrrun.dll即可。如想关闭FSO权限,在上述命令中加/u参数。注册表中的键值位置:HKEY_CLASS_BOOT\F.S.O .FSO中有个方法是CreateFolder,但是这个方法只能在其上一级文件夹存在的情况下创建新的文件夹,所以我就写了一个自动创建多级文件夹的函数,在生成静态页面等方面使用非常方便。函数:

以下为引用的内容:
’ --------------------------------
’ 自动创建指定的多级文件夹
’ strPath为绝对路径
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

下载本文示例代码


使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数使用FSO自动创建多级文件夹的函数
阅读(128) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~