当前位置:网站首页>Create directories and subdirectories circularly
Create directories and subdirectories circularly
2022-07-25 12:24:00 【Spring buds and summer lotus_ seven hundred and twenty-eight mi】
void RecursiveDirectory(std::wstring wstrDir)
{
if (wstrDir.length() <= 3)// It's the root directory , No need to create a directory
{
return;
}
if (wstrDir[wstrDir.length() - 1] == L'\\')
{
wstrDir.erase(wstrDir.end() - 1);
}
// Modify file properties
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(wstrDir.c_str(), &wfd); // lookup
if (hFind != INVALID_HANDLE_VALUE)
{
FindClose(hFind);
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
return;
}
// Failed to create the local directory of the current directory
if (CreateDirectory(wstrDir.c_str(), NULL) == false)
{
// Back to a higher directory
std::wstring wstrNewDir = wstrDir;
while (wstrNewDir[wstrNewDir.length() - 1] != L'\\') // Retreat to the previous directory of the current directory
{
wstrNewDir.erase(wstrNewDir.length() - 1);
}
// delete '\'
wstrNewDir.erase(wstrNewDir.length() - 1); // delete '\'
// Recursion into
RecursiveDirectory(wstrNewDir); // Recursion of this function , Then create a directory
// After recursive exit, create the directory that failed before
CreateDirectory(wstrDir.c_str(), NULL); // Recursively returns , Create a directory on the existing directory
}
// Multi level directory created successfully
}
边栏推荐
- Eureka usage record
- 给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享
- Communication bus protocol I: UART
- Visualize the training process using tensorboard
- Meta learning (meta learning and small sample learning)
- pytorch环境配置及基础知识
- 通信总线协议一 :UART
- OSPF comprehensive experiment
- R语言使用lm函数构建多元回归模型(Multiple Linear Regression)、使用step函数构建前向逐步回归模型筛选预测变量的最佳子集、scope参数指定候选预测变量
- Feign使用
猜你喜欢

WPF项目入门1-简单登录页面的设计和开发

MySQL exercise 2

Intelligent information retrieval (overview of intelligent information retrieval)

Visualize the training process using tensorboard

【黑马早报】运营23年,易趣网宣布关停;蔚来对大众CEO抛出橄榄枝;华为天才少年曾放弃360万年薪;尹烨回应饶毅炮轰其伪科学...

Hystrix使用

Week303 of leetcode (20220724)

MySQL练习二

Hydrogen entrepreneurship competition | Liu Yafang, deputy director of the science and Technology Department of the National Energy Administration: building a high-quality innovation system is the cor

Introduction to the scratch crawler framework
随机推荐
Technical management essay
1.1.1 欢迎来到机器学习
PyTorch主要模块
WPF project introduction 1 - Design and development of simple login page
【9】 Coordinate grid addition and adjustment
【五】页面和打印设置
【4】 Layout view and layout toolbar usage
Figure neural network for recommending system problems (imp-gcn, lr-gcn)
Communication bus protocol I: UART
Dr. water 2
PyTorch进阶训练技巧
Ansible
Eureka registration center opens password authentication - record
【十一】矢量、栅格数据图例制作以及调整
aaaaaaaaaaA heH heH nuN
【3】 DEM mountain shadow effect
Introduction to the scratch crawler framework
Resttemplate and ribbon are easy to use
Pytorch advanced training skills
马斯克的“灵魂永生”:一半炒作,一半忽悠