首页
社区
课程
招聘
[求助]用tc新建文件夹如何实现???
2006-4-15 23:07 5420

[求助]用tc新建文件夹如何实现???

2006-4-15 23:07
5420
如果我想要用tc在d盘创建一个文件夹,并向其中写入程序运行生成的文件,具体应该如何实现?
好象用c调用外部dos可以实现,但具体应该如何还不知道
麻烦指点,最好是能写出例子,
如果能用其它方式实现也可以,
小弟感激

阿里云助力开发者!2核2G 3M带宽不限流量!6.18限时价,开 发者可享99元/年,续费同价!

收藏
点赞0
打赏
分享
最新回复 (3)
雪    币: 235
活跃值: (100)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
lemony 1 2006-4-16 00:42
2
0
dos命令
md

系统API
CreateDirectory
雪    币: 217
活跃值: (99)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
dwing 1 2006-4-16 15:17
3
0
int _mkdir( const char *dirname );

Return Value

Each of these functions returns the value 0 if the new directory was created. On an error the function returns ?1 and sets errno as follows:

EEXIST

Directory was not created because dirname is the name of an existing file, directory, or device

ENOENT

Path was not found

Parameter

dirname

Path for new directory

Remarks

The _mkdir function creates a new directory with the specified dirname. _mkdir can create only one new directory per call, so only the last component of dirname can name a new directory. _mkdir does not translate path delimiters. In Windows NT, both the backslash ( \) and the forward slash (/ ) are valid path delimiters in character strings in run-time routines.

_wmkdir is a wide-character version of _mkdir; the dirname argument to _wmkdir is a wide-character string. _wmkdir and _mkdir behave identically otherwise.

Example

/* MAKEDIR.C */

#include <direct.h>
#include <stdlib.h>
#include <stdio.h>

void main( void )
{
   if( _mkdir( "\\testtmp" ) == 0 )
   {
      printf( "Directory '\\testtmp' was successfully created\n" );
      system( "dir \\testtmp" );
      if( _rmdir( "\\testtmp" ) == 0 )
        printf( "Directory '\\testtmp' was successfully removed\n"  );
      else
         printf( "Problem removing directory '\\testtmp'\n" );
   }
   else
      printf( "Problem creating directory '\\testtmp'\n" );
}

Output

Directory '\testtmp' was successfully created   
Volume in drive C is CDRIVE
Volume Serial Number is 0E17-1702

Directory of C:\testtmp

05/03/94  12:30p        <DIR>           .
05/03/94  12:30p        <DIR>           ..
               2 File(s)          0 bytes
                             17,358,848 bytes free
Directory '\testtmp' was successfully removed
雪    币: 211
活跃值: (21)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
caplsc 2006-4-17 16:59
4
0
感谢楼上两位,
我还想问一下,能不能让c程序运行生成的文件直接放到一个指定的目录(想放在什么目录下就能放在什么目录下,通过程序本身能实现吗???????
游客
登录 | 注册 方可回帖
返回