使用MakeSureDirectoryPathExists 创建多级目录
来源:互联网 发布:什么牌子的美工钢笔好 编辑:程序博客网 时间:2024/06/06 08:45
The MakeSureDirectoryPathExists function creates all the directories in the specified DirPath, beginning with the root.
BOOLMakeSureDirectoryPathExists(PCSTRDirPath);
Parameters
- DirPath
- [in] Pointer to a null-terminated string that specifies a valid path name. If the final component of the path is a directory, not a file name, the string must end with a backslash (/) character.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.
Remarks
Each directory specified is created, if it does not already exist. If only some of the directories are created, the function will return FALSE.
All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.
Requirements
Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires DbgHelp.dll on Windows NT 4.0 and Windows Me/98/95.
Header: Declared in Dbghelp.h.
Library: Use Dbghelp.lib.
函数功能描述:该函数创建一个从根目录开始的完整的指定路径.
.函数原型:
BOOL MakeSureDirectoryPathExists(PCSTR DirPath);
.参数:
DirPath [in] : 指向一个以NULL结尾的包含正确的指定的路径名,如果路径名的结尾部分不是文件名而是文件夹,那么要以'/'为结束符.
.返回值:
函数成功返回TRUE;
函数失败返回FALSE;要获得具体错误信息用GetLastError();
.备注:
每一级目录如果不存在就创建它,如果只有一些目录被创建了,那么函数返回FALSE.
.示例代码段:
在用MakeSureDirectoryPathExists前,要在Project->Settings...->Link->/Object/library modules中加入imagehlp.lib.
{
BOOL bRet=MakeSureDirectoryPathExists("f://Directory1//Directory2//Directory3//");
//创建目录,要注意结尾"//".
ASSERT(bRet);
bRet=MakeSureDirectoryPathExists("f://Directory1//Directory2//Directory3");
//创建目录,但不创建Directory3,因为没有'//'结尾.
ASSERT(bRet);
bRet=MakeSureDirectoryPathExists("f://Directory1//Directory2//Directory3//test.txt");
//创建目录,但不创建文件,可以不用'//'结尾.
ASSERT(bRet);
}
.使用条件:
Windows NT/2000: 要求是Windows NT 3.1或后续版本。
Windows 95/98: 要求是 Windows 95或后续版本。
头文件: 在Dbghelp.h中定义.
静态库: Dbghelp.lib.
- 使用MakeSureDirectoryPathExists 创建多级目录
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- VC++ MFC 创建多级目录的方法 MakeSureDirectoryPathExists (另附 文件、目录操作类)
- 使用VC创建多级目录
- 创建多级目录
- php创建多级目录
- SHCreateDirectoryEx 创建多级目录
- VC创建多级目录
- C++ 创建多级目录
- 递归创建多级目录
- 创建多级目录
- 创建多级目录
- 创建多级目录
- VB创建多级目录
- 创建多级目录
- C++ 创建多级目录
- 多级目录创建
- VC创建多级目录
- 从数据库取出一个时间字段,当取出的时间超过当前时间就显示"1" 不超过当前时间就显示"0"
- Hibernate笔记之6数据关联一对一
- C/C++程序BUG检查方法步骤
- 如何查询端口被占用及停止程序的方法
- 修改MySQL表的属性
- 使用MakeSureDirectoryPathExists 创建多级目录
- C/C++:学习用法一 sizeof 用法
- 网络游戏中,玩家数据同步的一种简单实现
- sql2000与sql2005的一些语法区别
- 日期 处 理
- Oracle中drop user和drop user cascade的区别
- Ext中动态改变控件的readOnly属性
- GSM AT指令
- CASIO DT930数据采集器