CreateDirectory

转自:百度百科 http://baike.baidu.com/view/1288758.htm


编辑本段简介

CreateDirectory,  CreateDirectoryEx

编辑本段C++

This function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
A remote application interface (RAPI) version of this function exists, and it is named  CeCreateDirectory.
BOOLCreateDirectory(LPCTSTR lpPathName , LPSECURITY_ATTRIBUTES lpSecurityAttributes );
Parameters lpPathName [in] Long pointer to a null-terminated string that specifies the path of the directory to be created. There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the  CreateDirectory function parses paths.
lpSecurityAttributes [in] Ignored; set to NULL. Return ValuesNonzero indicates success. Zero indicates failure. To get extended error information, call  GetLastError.
RemarksSome file systems, such as NTFS, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.
第一个参数值为文件夹名称第二个参数值为安全属性一般设置为NULL即可。如果正确创建,返回值为1,如果没有正常创建文件夹,则返回0。
特别的:该函数每次调用时都只能创建一级文件夹,即文件夹中不能再包含子文件夹。
当希望创建含有子文件夹的文件夹时,可以先使用该函数创建一级文件夹,然后再使用该函数在一级文件夹下创建子文件夹。如:
希望创建:d:\\TEST\\temp,
则:CString str = “d:\\TEST”;
CreateDirectory(str, NULL);
str = str + “\\temp”;
CreateDirectory(str, NULL);

编辑本段VB声明

Declare Function CreateDirectory& Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpNewDirectory As String, lpSecurityAttributes As SECURITY_ATTRIBUTES)
Declare Function CreateDirectoryEx& Lib "kernel32" Alias "CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal lpNewDirectory As String, lpSecurityAttributes As SECURITY_ATTRIBUTES)

编辑本段说明

创建一个新目录

编辑本段返回值

Long,非零表示成功,零表示失败。会设置GetLastError

编辑本段参数表

参数 类型及说明
lpTemplateDirectory String,指定一个模板目录的名字,从中复制默认属性(比如目录中文件的默认压缩方式)。如设为vbNullString,则表示不使用模板
lpNewDirectory String,新目录的名字
lpSecurityAttributes SECURITY_ATTRIBUTES,这个结构定义了目录的安全特性——如果操作系统支持的话
Windows API
This function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
A RAPI version of this function exists, and it is named CeCreateDirectory (RAPI).
BOOL CreateDirectory(
LPCTSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
Parameters
lpPathName
[in] Long pointer to a null-terminated string that specifies the path of the directory to be created.
There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the CreateDirectory function parses paths.
lpSecurityAttributes
[in] Ignored; set to NULL.
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
Remarks
Some file systems, such as NTFS file system, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.
Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.
See Also
CeCreateDirectory (RAPI) | CreateFile |  RemoveDirectory

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值