已有文件夹E:\KKK
想在kkk中再新建一个子文件夹
e:\kkk\aaa\
aaa是通过 text1.text中的内容得到的
就是说text1.text中是什么那就新建一个叫什么名字的文件夹
例text1.text=你好则新建e:\kkk\你好\如text1.text=今天则新建eee:\kkk\今天\
谢了

解决方案 »

  1.   

    Private Sub Command1_Click()
        Dim s As String
        s = "e:\kkk"
        If Dir(s, vbDirectory) = "" Then
            MkDir s
        End If
        MkDir s & "\" & Text1.Text
    End Sub
      

  2.   

    '创建目录 
    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 '创建目录 
    Public Function CreateNewDirectory(NewDirectory As String) 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 Mid(sPath, Len(sPath) - 1) <> "\" Then 
            sPath = sPath & "\" 
        End If     iCounter = 1 
        Do Until InStr(iCounter, sPath, "\") = 0 
            iCounter = InStr(iCounter, sPath, "\") 
            sTempDir = Mid(sPath, 1, iCounter) 
            sDirTest = Dir(sTempDir) 
            iCounter = iCounter + 1         SecAttrib.lpSecurityDescriptor = &O0 
            SecAttrib.bInheritHandle = False 
            SecAttrib.nLength = Len(SecAttrib) 
            bSuccess = CreateDirectory(sTempDir, SecAttrib) 
        Loop 
        CreateNewDirectory = NewDirectory 
    End Function