Modul
Isi
Indeks 🔎︎

# MkDir Statement

Membuat direktori baru pada media data.

## Sintaksis:

    MkDir Teks As String

## Parameter:

Text: Any string expression that specifies the name and path of the directory to be created. You can also use URL notation.

If the path is not determined, the directory is created in the current directory.

## Kode kesalahan:

5 Tidak sah dalam pemanggilan prosedur

76 Jalur tidak ketemu

## Contoh:

    Sub ExampleFileIO

    ' Contoh bagi fungsi-fungsi untuk mengorganisasikan berkas

    Const sFile1 As String = "file://c|/autoexec.bat"

    Const sDir1 As String = "file://c|/Temp"

    Const sSubDir1 as String ="Test"

    Const sFile2 as String = "Copied.tmp"

    Const sFile3 As String = "Renamed.tmp"

    Dim sFile As String

        sFile = sDir1 + "/" + sSubDir1

        ChDir( sDir1 )

        If Dir(sSubDir1,16)="" then ' Apakah direktorinya ada ?

            MkDir sSubDir1

            MsgBox sFile,0,"Membuat direktori"

        End If

        sFile = sFile + "/" + sFile2

        FileCopy sFile1 , sFile

        MsgBox fSysURL(CurDir()),0,"Direktori saat ini"

        MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Waktu pembuatan"

        MsgBox sFile & Chr(13)& FileLen( sFile ),0,"Panjang berkas"

        MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"Atribut berkas"

        Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3

        ' Rename in the same directory

        sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3

        SetAttr( sFile, 0 ) 'Menghapus semua atribut

        MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"Atribut berkas yang baru"

        Kill sFile

        RmDir sDir1 + "/" + sSubDir1

    End Sub

    ' Converts a system path in 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