VC 快速创建多层文件夹&文件的创建、打开、读写、操作
2016-06-06 23:13
525 查看
<span style="font-size: 16px;"><strong>BOOL CreateDirectory( LPCTSTR</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/shen_001/article/details/6823049" style="color: rgb(51, 102, 153); text-decoration: none;">lpPathName</a></em></span><span style="font-size: 16px;"><strong>, LPSECURITY_ATTRIBUTES</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/shen_001/article/details/6823049" style="color: rgb(51, 102, 153); text-decoration: none;">lpSecurityAttributes</a></em></span><strong> <span style="font-size: 16px;">);</span></strong> <span style="color: rgb(255, 102, 102);">这个是大多数用户都知道的,但是这个有缺点,只能是一层一层的创建。。。很是麻烦!!!</span>
下面给大家介绍一个函数:
<span style="font-size: 16px;"><strong>BOOL MakeSureDirectoryPathExists( PCSTR</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/shen_001/article/details/6823049" style="color: rgb(51, 102, 153); text-decoration: none;">DirPath</a></em></span><strong> <span style="font-size: 16px;">);</span></strong> <table class="psdkRequirements "><tbody><tr><th><span style="font-size: 16px;">Client</span></th><td><span style="font-size: 16px;">Requires Windows XP or Windows 2000 Professional.</span></td></tr><tr><th><span style="font-size: 16px;">Server</span></th><td><span style="font-size: 16px;">Requires Windows Server 2003 or Windows 2000 Server.</span></td></tr><tr><th><span style="font-size: 16px;">Redistributable</span></th><td><span style="font-size: 16px;">Requires DbgHelp.dll on Windows NT 4.0 and Windows Me/98/95.</span></td></tr><tr><th><span style="font-size: 16px; color: rgb(255, 0, 0);">Header</span></th><td><p><span style="font-size: 16px; color: rgb(255, 0, 0);">Declared in Dbghelp.h.</span></p></td></tr><tr><th><span style="font-size: 16px; color: rgb(255, 0, 0);">Library</span></th><td><p><span style="font-size: 16px; color: rgb(255, 0, 0);">Link to Dbghelp.lib.</span></p></td></tr><tr><th><span style="font-size: 16px; color: rgb(255, 0, 0);">DLL</span></th><td><span style="font-size: 16px; color: rgb(255, 0, 0);">Requires Dbghelp.dll.</span></td></tr></tbody></table>
这个是MSDN上说的需要 Dbghelp.h 但是这样不管你怎么实验,都是不成功!
把头文件改成如下就可以正确使用了
#include "imagehlp.h"
#pragma comment(lib,"imagehlp.lib")
MakeSureDirectoryPathExists("F:\\DVR\\123\\123\\dfd\\asdf\\a\\adf\\");
1.文件路径完全不存在。
2.文件路径存在一部分。
这些都是完全可以实现!!
相关文章推荐
- VC中实现文字竖排的简单方法(推荐)
- VC中CDC、HDC、pDC区别与联系及相互转换
- Visual C++中MFC消息的分类
- VC实现获取当前正在运行的进程
- vc中SendMessage自定义消息函数用法实例
- VC实现让关闭按钮成灰色不可用的方法
- VC++中的字体设置方法详解
- VC程序设计中CreateProcess用法注意事项
- VC实现批量删除指定文件的方法
- MFC中Radio Button的用法详解
- MFC对话框中添加状态栏的方法
- MFC创建右键弹出菜单的方法
- MFC中动态创建控件以及事件响应实现方法
- C++ 关于MFC多线程编程的注意事项
- vc中使用SendMessage自定义消息函数
- MFC程序对文件的处理方法
- vc提示unexpected end of file found的原因分析
- MFC自定义消息的实现方法
- vc获取计算机名和ip地址的方法
- MFC实现在文件尾追加数据的方法