include("../include.php"); writeHeader("Create an entire path", "Programming » Visual Basic 6 » Visual Basic 6 Code » File and Disk access » ");?>
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 'Add this code to the form's General Declarations procedure: 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