VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 快速建立目录
发表评论(0)作者:, 平台:, 阅读:12844, 日期:2000-03-12
快速建立目录 98-8-22

声明:

Private Type SECURITY_ATTRIBUTES

nLength As Long

lpSecurityDescriptor As Long

bInheritHandle As Long

End Type

Private Declare Function CreateDirectory Lib "kernel32" _

Alias "CreateDirectoryA" (ByVal lpPathName As String, _

lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

函数:

'Call CreateNewDirectory("c:\test\directory\vb\tips\")

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

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

'create directory

SecAttrib.lpSecurityDescriptor = &O0

SecAttrib.bInheritHandle = False

SecAttrib.nLength = Len(SecAttrib)

bSuccess = CreateDirectory(sTempDir, SecAttrib)

Loop

End Sub