问题描述
我需要在VS 2008中使用mkdir c ++函数,该函数带有两个参数,并且已从VS 2005中弃用。
I need to use the mkdir c++ function in VS 2008 which takes two arguments and is deprecated from VS 2005.
但是在我们的代码和需要编写一个独立的产品(仅包含mkdir函数)来调试某些东西。
However this function is used in our code and I need to write a standalone product (containing only mkdir function) to debug something.
我需要导入哪些头文件?我使用了direct.h,但是编译器抱怨该参数不带2个参数(原因是此函数在VS 2005中已弃用)。
What header files do I need to import? I used direct.h, however compiler complains that the argument does not take 2 arguments (reason for this is the function was deprecated in VS 2005).
mkdir("C:\hello",0);
推荐答案
如果要编写跨平台代码,则可以可以使用 boost :: filesystem
例程
If you want to write cross-platform code, you can use boost::filesystem
routines
#include <boost/filesystem.hpp>
boost::filesystem::create_directory("dirname");
这确实增加了库依赖性,但是您可能还会使用其他文件系统例程,并且 boost :: filesystem
具有一些不错的接口。
This does add a library dependency but chances are you are going to use other filesystem routines as well and boost::filesystem
has some great interfaces for that.
如果只需要创建一个新目录,并且仅将使用VS 2008,您可以使用 _mkdir()
,正如其他人指出的那样。
If you only need to make a new directory and if you are only going to use VS 2008, you can use _mkdir()
as others have noted.
这篇关于mkdir c ++函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!