函数参考


DirCreate

新建一个目录/文件夹.

DirCreate ( "路径" )

参数

路径 要创建的目录路径.

返回值

成功: 返回值为1.
失败: 返回值为0,说明在创建目录的过程中遇到错误.

注意/说明

在要创建的目录的父目录(上一级目录)不存在时,这些父目录也会被创建.

相关

DirRemove, FileCopy

示例/演示


Local $sFldr1 = "C:\Test1\"
Local $sFldr2 = "C:\Test1\Folder1\"
Local $sFldr3 = "C:\Test1\Folder1\Folder2\"
If DirGetSize($sFldr1) = -1 Then
    DirCreate($sFldr3)
    Local $explorer = RunWait("explorer /root, C:\Test1\Folder1")
    Local $handle = WinGetHandle($explorer)
    MsgBox(262144, "Message", "Explorer is opened with Folder2 displayed.")
    DirRemove($sFldr3, 1)
    MsgBox(262144, "Message", "The sub folder: Folder2 has been deleted.")
    WinClose($handle)
    DirRemove($sFldr2) ;clean up test folders
    DirRemove($sFldr1) ;clean up test folders
Else
    MsgBox(48, $sFldr1, "Directory already exists!")
EndIf