VC 快速創建多層文件夾


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM