Příkaz MkDir

Vytvoří na datovém médiu nový adresář.

Syntaxe:


MkDir Text As String

Parametry:

Text: Řetězec určující název a cestu nového adresáře. Také je možné použít URL notaci.

Pokud není určena cesta, adresář se vytvoří v aktuálním adresáři.

Chybové kódy:

5 Neplatné volání procedury

76 Cesta nenalezena

Příklad:


Sub ExampleFileIO
' Příklad funkcí pro správu souborů
Const sFile1 As String = "file://c|/autoexec.bat"
Const sDir1 As String = "file://c|/Temp"
Const sSubDir1 as String ="Test"
Const sFile2 as String = "Kopie.tmp"
Const sFile3 as String = "Prejmenovany.tmp"
Dim sFile As String
    sFile = sDir1 + "/" + sSubDir1
    ChDir( sDir1 )
    If Dir(sSubDir1,16)="" then ' Existuje adresář?
        MkDir sSubDir1
        MsgBox sFile,0,"Vytvořit adresář"
    End If
    sFile = sFile + "/" + sFile2
    FileCopy sFile1 , sFile
    MsgBox fSysURL(CurDir()),0,"Aktuální adresář"
    MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Čas vytvoření"
    MsgBox sFile & Chr(13)& FileLen( sFile ),0,"Délka souboru"
    MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"Atributy souboru"
    Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3
    ' Přejmenování ve stejném adresáři
    sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3
    SetAttr( sFile, 0 ) 'Smaže všechny atributy
    MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"Nové atributy souboru"
    Kill sFile
    RmDir sDir1 + "/" + sSubDir1
End Sub
 
' Převede systémovou cestu na URL
Function fSysURL( fSysFp As String ) As String
Dim iPos As String
    iPos = 1
    iPos = Instr(iPos,fSysFp, getPathSeparator())
    Do While iPos > 0
        Mid( fSysFp, iPos , 1,"/")
        iPos = Instr(iPos+1,fSysFp, getPathSeparator())
    Loop
    ' the colon with DOS
    iPos = Instr(1,fSysFp,":")
    If iPos > 0 Then Mid( fSysFp, iPos , 1,"|")
    fSysURL = "file://" & fSysFp
End Function

Podpořte nás!