Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

利用API创建文件目录

时 间:2008-05-19 08:17:56
作 者:UMVSOFT整理   ID:16  城市:江阴
摘 要:利用API创建文件目录

正 文:

利用API创建文件目录


Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long


Private Type SECURITY_ATTRIBUTES

nLength As Long

lpSecurityDescriptor As Long

bInheritHandle As Long

End Type


Sub Main()

\'在C盘创建了"VB编程乐园"目录

Call CreateNewDirectory("C:\\VB编程乐园")

MsgBox "在C盘创建了 VB编程乐园 目录"

End Sub


Public Sub CreateNewDirectory(NewDirectory As String)

Dim sDirTest As String

Dim SecAttrib As SECURITY_ATTRIBUTES

Dim bSuccess As Boolean

Dim sPath As String

Dim iCounter As Integer

Dim sTempDir As String

Dim iFlag As Integer

iFlag = 0

sPath = NewDirectory


If Right(sPath, Len(sPath)) <> "\\" Then

sPath = sPath & "\\"

End If


iCounter = 1

Do Until InStr(iCounter, sPath, "\\") = 0

iCounter = InStr(iCounter, sPath, "\\")

sTempDir = Left(sPath, iCounter)

sDirTest = Dir(sTempDir)

iCounter = iCounter + 1


\'创建目录


SecAttrib.lpSecurityDescriptor = &O0

SecAttrib.bInheritHandle = False

SecAttrib.nLength = Len(SecAttrib)

bSuccess = CreateDirectory(sTempDir, SecAttrib)

Loop

End Sub


Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助