当前位置:网站首页>循环创建目录与子目录
循环创建目录与子目录
2022-07-25 11:33:00 【春蕾夏荷_728297725】
void RecursiveDirectory(std::wstring wstrDir)
{
if (wstrDir.length() <= 3)//是根目录,无需创建目录
{
return;
}
if (wstrDir[wstrDir.length() - 1] == L'\\')
{
wstrDir.erase(wstrDir.end() - 1);
}
// 修改文件属性
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(wstrDir.c_str(), &wfd); // 查找
if (hFind != INVALID_HANDLE_VALUE)
{
FindClose(hFind);
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
return;
}
// 创建当前目录的地目录失败
if (CreateDirectory(wstrDir.c_str(), NULL) == false)
{
// 退到上一级目录
std::wstring wstrNewDir = wstrDir;
while (wstrNewDir[wstrNewDir.length() - 1] != L'\\') // 撤到当前目录的上一个目录
{
wstrNewDir.erase(wstrNewDir.length() - 1);
}
// delete '\'
wstrNewDir.erase(wstrNewDir.length() - 1); // delete '\'
// 递归进入
RecursiveDirectory(wstrNewDir); // 递归本函数,再创建目录
// 递归退出后创建之前失败的目录
CreateDirectory(wstrDir.c_str(), NULL); // 递归返回,在存在的目录上再建目录
}
// 多级目录创建成功
}
边栏推荐
- NLP knowledge - pytorch, back propagation, some small pieces of notes for predictive tasks
- Scott+Scott律所计划对Yuga Labs提起集体诉讼,或将确认NFT是否属于证券产品
- GPT plus money (OpenAI CLIP,DALL-E)
- R语言使用lm函数构建多元回归模型(Multiple Linear Regression)、使用step函数构建前向逐步回归模型筛选预测变量的最佳子集、scope参数指定候选预测变量
- NLP的基本概念1
- 【AI4Code】《Contrastive Code Representation Learning》 (EMNLP 2021)
- Data transmission under the same LAN based on tcp/ip
- 防范SYN洪泛攻击的方法 -- SYN cookie
- selenium使用———安装、测试
- Median (two point answer + two point search)
猜你喜欢

【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021

Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge

Atomic 原子类

【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)

氢能创业大赛 | 国家能源局科技司副司长刘亚芳:构建高质量创新体系是我国氢能产业发展的核心

【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)

【CTR】《Towards Universal Sequence Representation Learning for Recommender Systems》 (KDD‘22)

OSPF comprehensive experiment

Analysis of TCP packet capturing using Wireshark

Those young people who left Netease
随机推荐
Power Bi -- these skills make the report more "compelling"“
Start with the development of wechat official account
The applet image cannot display Base64 pictures. The solution is valid
马斯克的“灵魂永生”:一半炒作,一半忽悠
利用wireshark对TCP抓包分析
selenium使用———安装、测试
How to solve the problem of the error reported by the Flink SQL client when connecting to MySQL?
Knowledge maps are used to recommend system problems (mvin, Ctrl, ckan, Kred, gaeat)
【RS采样】A Gain-Tuning Dynamic Negative Sampler for Recommendation (WWW 2022)
通过Referer请求头实现防盗链
Pycharm connects to the remote server SSH -u reports an error: no such file or directory
【AI4Code】《Unified Pre-training for Program Understanding and Generation》 NAACL 2021
Brpc source code analysis (V) -- detailed explanation of basic resource pool
Eureka注册中心开启密码认证-记录
Transformer变体(Sparse Transformer,Longformer,Switch Transformer)
[RS sampling] a gain tuning dynamic negative sampler for recommendation (WWW 2022)
After having a meal with trump, I wrote this article
aaaaaaaaaaA heH heH nuN
keepalived实现mysql的高可用
dirReader. Readentries compatibility issues. Exception error domexception