BOOL CreateDirectory( LPCTSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes ); 這個是大多數用戶都知道的,但是這個有缺點,只能是一層一層的創建。。。很是麻煩!!!
下面給大家介紹一個函數:
BOOL MakeSureDirectoryPathExists( PCSTR DirPath );
| 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.文件路徑存在一部分。
這些都是完全可以實現!!
jpg改rar
