c ++如何从一个路径创建一个目录 [英] c++ how to create a directory from a path

查看:283
本文介绍了c ++如何从一个路径创建一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当提供类似这样的路径时,创建目录的一种方便方法是:\server\foo\bar\

what is a convenient way to create a directory when a path like this is given: "\server\foo\bar\"

中间目录可能不存在。

CreateDirectory和mkdir只能创建目录的最后一部分,否则会产生错误。

CreateDirectory and mkdir only seem to create the last part of a directory and give an error otherwise.

平台是windows,MSVC编译器。

the platform is windows, MSVC compiler.

谢谢!

推荐答案

SHCreateDirectoryEx()可以执行此操作。它在XP SP2和更高版本的Windows上可用。

SHCreateDirectoryEx() can do that. It's available on XP SP2 and newer versions of Windows.

这篇关于c ++如何从一个路径创建一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆