当前位置:网站首页>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
}
边栏推荐
- 3.2.1 what is machine learning?
- mysql实现一张表数据插入另一张表
- [micro service ~sentinel] sentinel degradation, current limiting, fusing
- 【AI4Code】《InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees》ICSE‘21
- Transformer variants (routing transformer, linformer, big bird)
- 1.1.1 欢迎来到机器学习
- 搭建Vision Transformer系列实践,终于见面了,Timm库!
- pytorch环境配置及基础知识
- R language ggplot2 visualization: visualize the scatter diagram, add text labels to some data points in the scatter diagram, and use geom of ggrep package_ text_ The repl function avoids overlapping l
- Week303 of leetcode (20220724)
猜你喜欢

Intelligent information retrieval (overview of intelligent information retrieval)

919. 完全二叉树插入器 : 简单 BFS 运用题

Visualize the training process using tensorboard

记录一次线上死锁的定位分析

Fiddler抓包APP

通过Referer请求头实现防盗链

NLP knowledge - pytorch, back propagation, some small pieces of notes for predictive tasks

微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告

Eureka注册中心开启密码认证-记录

Sword finger offer 22. the penultimate node in the linked list
随机推荐
logstash
【二】栅格数据显示拉伸色带(以DEM数据为例)
scrapy 爬虫框架简介
Can't delete the blank page in word? How to operate?
【ROS进阶篇】第九讲 URDF的编程优化Xacro使用
PyTorch进阶训练技巧
Ups and downs of Apple's supply chain in the past decade: foreign head teachers and their Chinese students
MySQL练习二
Median (二分答案 + 二分查找)
WPF project introduction 1 - Design and development of simple login page
Dr. water 2
Azure Devops(十四) 使用Azure的私有Nuget仓库
Implement anti-theft chain through referer request header
Those young people who left Netease
919. Complete binary tree inserter: simple BFS application problem
Zero shot image retrieval (zero sample cross modal retrieval)
Eureka registration center opens password authentication - record
Brpc source code analysis (II) -- the processing process of brpc receiving requests
Atomic 原子类
利用wireshark对TCP抓包分析