VC 快速创建多层文件夹&文件的创建、打开、读写、操作

<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.文件路径存在一部分。

这些都是完全可以实现!!




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值