在VC ++中创建目录 [英] Creating directory in vc++

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

问题描述

如何在vc ++ mfc中创建目录树?
我正在尝试此代码

How can I create directory tree in vc++ mfc?
I am trying this code

char dirname[FILENAME_MAX] = {"c:\\new_directory\\"};
int erc;
erc = mkdir(dirname);



但它给出错误-``mkdir''是未声明的标识符



but it gives error- ''mkdir'' is undeclared identifier

推荐答案

请参阅 ^ ],并确保包含必要的标题.
See here[^] for details, and ensure that you include the necessary headers.


您可以尝试CreateDirectory();用于创建新目录

You can try CreateDirectory(); for create new directory

TCHAR szDirPath[] = TEXT("c:\\new_directory\\"");
if(!CreateDirectory(szDirPath,NULL))
{
 AfxMessageBox("Unable to create directory");
}



请检出头文件以使用mkdir(string)方法


嘿,亲爱的,您可能会像



Please check out header files to used mkdir(string) methods


Hey dear you may follows looping like

int i=0;
LOOP:    if(!CreateDirectory(szDirPath,NULL)&&(i!=5))  ///if you want to create 5  subdirectories inside and inside;
           {
              char BUFFER[100];
              itoa(i,BUFFER,10);
              SetCurrentDirectory(szDirPath);
              szDirPath=szDirPath+"\\Dir"+BUFFER;
               i++;
              goto LOOP;
            }


使用SHCreateDirectoryEx()递归创建文件夹路径.请参阅此处: http://msdn.microsoft.com/zh-CN /library/bb762131%28v=vs.85%29.aspx [
Use SHCreateDirectoryEx() to recursively create a folder path. See here: http://msdn.microsoft.com/en-us/library/bb762131%28v=vs.85%29.aspx[^]


这篇关于在VC ++中创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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