本文共 807 字,大约阅读时间需要 2 分钟。
转载来自:http://blog.csdn.net/shen_001/article/details/6823049
BOOL CreateDirectory( LPCTSTR , LPSECURITY_ATTRIBUTES );这个是大多数用户都知道的,但是这个有缺点,只能是一层一层的创建。。。很是麻烦!!!
下面给大家介绍一个函数:
BOOL MakeSureDirectoryPathExists( PCSTR ); Client Requires Windows XP or Windows 2000 Professional. Server Requires Windows Server 2003 or Windows 2000 Server. Redistributable Requires DbgHelp.dll on Windows NT 4.0 and Windows Me/98/95. Header Declared in Dbghelp.h. Library Link to Dbghelp.lib. DLL Requires Dbghelp.dll.
这个是MSDN上说的需要 Dbghelp.h 但是这样不管你怎么实验,都是不成功!
把头文件改成如下就可以正确使用了
#include "imagehlp.h" #pragma comment(lib,"imagehlp.lib")
MakeSureDirectoryPathExists("F:\\DVR\\123\\123\\dfd\\asdf\\a\\adf\\");
1.文件路径完全不存在。
2.文件路径存在一部分。
这些都是完全可以实现!!