春暖花开
雪化了,花开了,春天来了
posts - 149,comments - 125,trackbacks - 0

在指定目录下创建文件夹

在博客里,有人问我这个问题:如何在指定目录下创建文件夹。这个我还真的没有做过。用CreateFile,似乎里面也没有跟文件夹相关的任何东西。于是就在SDK中搜了一下,CreateDirectory。不错,这个就可以用来创建文件夹。

下面来仔细学习一下这个API

CreateDirectory

功能

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.

(创建一个新的文件夹。如果基本的文件系统在文件或文件夹上支持安全描述,那么该函数将在新建的文件夹上应用指定的安全描述)

原型:

BOOL CreateDirectory(
  LPCTSTR lpPathName, 
  LPSECURITY_ATTRIBUTES lpSecurityAttributes 
);

参数:

lpPathName:包含将被创建的文件夹路径的字符串,字符串的长度不超过MAX_PATH
lpSecurityAttributes:忽略,设为NULL

返回值:

成功则返回非零,失败则返回零。

备注:

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.

In Windows CE 5.0 and later, full path canonicalization is performed before CreateDirectory processes a path name. As a result, trailing backslashes that may appear in a user-provided path name are ignored.

一些文件系统,像NTFS文件系统,对于个别的文件或目录支持压缩或加密。以卷格式化的文件系统,一个新的目录将继承它父目录的压缩和加密特性。
Windows CE 5.0或以后的版本中,全路径的规范化将在CreateDirectory处理路径名字前执行。结果是,出现在用户指定的路径名中的反斜线将被忽略。
posted on 2009-07-21 18:14 Sandy 阅读(2728) 评论(0)  编辑 收藏 引用 所属分类: Windows Mobile

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理