i just want to know how to create folders using c++ code...i can make files usng iostream,but can folder?
i
Printable View
i just want to know how to create folders using c++ code...i can make files usng iostream,but can folder?
i
::CreateDirectory
Cheers
This would only work in Windows... ;)Quote:
Originally Posted by golanshahar
There is not platform-independent way of doing it...thus, you need to check what the C run-time or API of the correpsonding operating system has to offer...which one are you using?
i think that people working in unix/linux wouldnt ask that question ("folders":)Quote:
Originally Posted by Andreas Masur
thanks guys for replaying..
by the way i m using linux not windows...why would not linux users not ask that?!
i use mandrake 10.
Why? Aren't there folders in Linux? ;)Quote:
Originally Posted by l00p1n6
AFAIK, there should be a 'mkdir' function...Quote:
Originally Posted by deepinlife
There is relatively portable boost method create_directory.
no respectable *nix programmer would call them "folders". They are directories. :rolleyes:Quote:
Originally Posted by Andreas Masur
Well...I guess that I does not have that much respect for my *nix then (IOW, my directories can be folders if they want)... :eek:Quote:
Originally Posted by stober
Quote:
Originally Posted by golanshahar
Is ::CreateDirectory a Windows specific function? How to create directory using C++ on Linux?
Are there any C++ functions available (that create directory on Linux) written by someone who would like to share to others?
o/w; Is there a built-in C++ function that creates directory and will runs on Linux (no Windows specific stuff?
Thanks!
Windy
RoboTact has already given the answer. Use boost::filesystem and you'll have the bonus of having OS independent code.Quote:
Originally Posted by RoboTact
Andres also posted a function that is portable between *nix and MS-Windows -- mkdir().
i had to create directories in windows using VC++
I can get CreateDirectory to work only when the path is like " c:/face"
If I give "c:/face/images" it doesnt create the folder, not even face, any help would be appreciated.
if I have c:/face created then it creates ./image also :?
You'll need to iteratively create enclosed folders: first c:/face, then c:/face/images.Quote:
Originally Posted by bhas_purk
CreateDirectory() can only be used to create the final directory, if one or more intermediate directories do not exist, CreateDirectory() will fail with an error 3.
You may use SHCreateDirectoryEx() indeed, this fuction will generate a folder and its sub folders.
The thread that won't die. :confused: :eek:
lol, it never will :)
I know this is an old thread but this solution will work in both Windows and Linux.
char sysText[256];
sprintf( systext, "mkdir %s", path ); // path is a char * to the string representing the directory you want to create
system( systext );
I am having some difficult times with this too.
my code in MS Visual C++ 6.0 looks like
char dirname[FILENAME_MAX] = {"c:\\new_directory\\"};
int erc;
erc = mkdir(dirname);
so far it works fine.
.....................................
I am trying to do the same thing using MS Visual C++ 2010 Express
the same set of instructions are not accepted, is there something I should add/change?
thanks in advance
Try _mkdir().
I got back this
'_mkdir': identifier not found
could you please help me with the include file name, maybe it has changed ....
You can create directory in windows by using dis code ...................... jst pass da name of folder using char array
#include<iostream>
using namespace std;
void main()
{
system("mkdir D:foldername");
}
:rolleyes:Quote:
Well, [email protected] seems to be not a reader, he/she is a writer! :D
Why system() is evilQuote:
p.s. This thread is 6 years old.