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盤創(chuàng)建了"Accessbbs"目錄 Call CreateNewDirectory("C:\Accessbbs") MsgBox "在C盤創(chuàng)建了 Accessbbs 目錄" 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 '創(chuàng)建目錄 SecAttrib.lpSecurityDescriptor = &O0 SecAttrib.bInheritHandle = False SecAttrib.nLength = Len(SecAttrib) bSuccess = CreateDirectory(sTempDir, SecAttrib) Loop End Sub |
|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國
( 粵ICP備10043721號-1 )
GMT+8, 2025-7-17 01:09 , Processed in 0.075222 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.