MakeSureDirectoryPathExists
2010-12-23 09:09
921 查看
MakeSureDirectoryPathExists
Function
Creates all the directories in the specified path, beginning with theroot.
BOOL WINAPI MakeSureDirectoryPathExists( __in PCSTR DirPath );
Parameters
DirPathA 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 Value
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 onlysome of the directories are created, the function will return FALSE.
This function does not support Unicode strings. To specify a Unicode path,
use the SHCreateDirectoryEx
function.
All DbgHelp functions, such as this one, are single threaded. Therefore,
calls fr
om 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
Redistributable | Requires DbgHelp.dll 5.1 or later. |
---|---|
Header | Declared in Dbghelp.h. |
Library | Use Dbghelp.lib. |
DLL | Requires Dbghelp.dll. |
]#include "stdafx.h" #include <Windows.h> //创建路径使用,MSDN里说的头文件和库应该是有问题的! #include <imagehlp.h> #pragma comment(lib,"imagehlp.lib") int _tmain(int argc, _TCHAR* argv[]) { //Creates all the directories in the specified path MakeSureDirectoryPathExists("C://test//aa//a.txt");//成功 MakeSureDirectoryPathExists("C://test//aa//bb//a.txt");//成功 MakeSureDirectoryPathExists("C://test//aa//cc//");//成功 MakeSureDirectoryPathExists(".//test//");//成功 MakeSureDirectoryPathExists("..//test//");//成功 MakeSureDirectoryPathExists("./test2/");//不成功 MakeSureDirectoryPathExists("C:/test2/aa/a.txt");//不成功 MakeSureDirectoryPathExists("C://test2");//不成功 return 0; }
MSDN里说的头文件和库应该是有问题的!
相关文章推荐
- MakeSureDirectoryPathExists与CreateDirectory的区别
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- MakeSureDirectoryPathExists和CreateDirectory的区别
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- 使用MakeSureDirectoryPathExists 创建多级目录
- windows api一日一练(dbghelp sdk)-002-MakeSureDirectoryPathExists,SearchTreeForFile
- 2014-03-14周五工作日志:检查指定目录是否存在的函数MakeSureDirectoryPathExists
- MakeSureDirectoryPathExists与CreateDirectory的区别
- MakeSureDirectoryPathExists检查目录是否存在
- VC++ MFC 创建多级目录的方法 MakeSureDirectoryPathExists (另附 文件、目录操作类)
- MakeSureDirectoryPathExists参数不能是正斜杠(“/”)
- Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor
- Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "te
- Unable to enable crypto on TCP connection make sure the sslcafile or sslcapath option are properly
- Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "te
- ubuntu vmware xp Could not open /dev/vmmon: No such file or directory. Please make sure that the ke
- cordova安装插件的时候提示: “git” command line tool is not installed: make sure it is accessible on your PATH.
- git clone时出现Please make sure you have the correct access rights and the repository exists.错误
- Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "te