Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to create folder at a specified path by using c++ ?

Status
Not open for further replies.

ehsanelahimirza

Full Member level 6
Joined
Feb 24, 2006
Messages
334
Helped
28
Reputation
56
Reaction score
7
Trophy points
1,298
Activity points
3,570
foldering in c++

hi

plz tell me how to create folder by using c++ at a specified path
 

Re: foldering in c++

U can use system() function to create folder.
System function is used to execute dos commands from a program in Turbo C
e.g.
system("md MyFolder");
it will create a folder is the current working directory
 

Re: foldering in c++

hi

which libraries r to b included for this system function
i mean header files

thanks
 

foldering in c++

hi
in windows platform use CreateDirectory
 

Re: foldering in c++

nothing is working

plz tell me how to do this foldering
 

Re: foldering in c++

Hi All,

This is a working code. The library tobe included is dos.h. Please use turboC compiler. The operation system used is windows only.

#include<stdio.h>
#include<dos.h>
int main()
{
system("mkdir Myfolder");
}
 

foldering in c++

hi
where r u programming?
dos, linux, windows??????
 

Re: foldering in c++

operating systern is windows XP.
That will surely work in DOS also.

Added after 8 minutes:

It will work in linux also. Here the library to be included in stdlib.h

#include<stdlib.h>
int main()
{
system("mkdir Myfolder");
}
 

Re: foldering in c++

sreeni said:
operating systern is windows XP.
That will surely work in DOS also.

Added after 8 minutes:

It will work in linux also. Here the library to be included in stdlib.h

#include<stdlib.h>
int main()
{
system("mkdir Myfolder");
}


thanks

its working

a good thing that when u give space between some name it will create another folder with the name after space i.e. it takes space as end of folder name and start of new one.

also it is generating folder at any specified path

like

system("mkdir c:\\newfolder")
 

Re: foldering in c++

Check it in cpluplus.org . it is goog site
 

Re: foldering in c++

#include <stdlib.h>

int main()
{
int i;
for(i=0;i<10;i++)
{
system ("mkdir %d",i);
}
}
1.i need to create many folder each name depending on variable is it possible to create with the above code
2.can u suggest me some metod to create many folders

the above code i used in visual c++ compiler in win xp
 

Re: foldering in c++

Here is the example which works indpendent of platform


mkdir : Creates a directory.

Syntax:
int mkdir(const char *path);

Prototype in:
dir.h

Remarks:
mkdir creates a new directory from the given
path name path.

Return Value:
mkdir returns the value 0 if the new directory
was created.

On error, a value of -1 is returned, and the
global variable errno is set to one of the
following values:

Setting Description
EACCES Permission denied
ENOENT No such file or directory

Portability:
mkdir is available on UNIX System V, though it
takes an additional file-mode parameter.

Example:
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dir.h>

int main(void)
{
int status;

clrscr();
status = mkdir("asdfjklm");
(!status) ? (printf("Directory created\n")) :
(printf("Unable to create directory\n"));

getch();
return 0;
}
 

Re: foldering in c++

the compiler for windows is visual and turbo c

which r used for linux
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top