Please tell me how to check a directory is exist or not? If it not exist, then how to create?
Thanks.
qi1996@lycos.com
Please tell me how to check a directory is exist or not? If it not exist, then how to create?
Thanks.
qi1996@lycos.com
Code:#include <iostream.h> #include <process.h> #include <stdio.h> #include <conio.h> #include <string.h> void main() { char path[1024], *MakeDir; cout<<"\nWhat folder do you wish to check/create?\n"; cin >> path; int length1 = strlen("mkdir "); int length2 = strlen(path); MakeDir = new char [length1 + length2 + 1]; strcpy(MakeDir, "mkdir "); strcat(MakeDir, path); system(MakeDir); if(!MakeDir) { printf("This folder exists."); } else { printf("There was no directory. A directory has been created."); } getch(); }
That one messes up a bit, here, use this one instead :
Code:#include <iostream.h> #include <process.h> #include <stdio.h> #include <conio.h> #include <string.h> void main() { char path[1024], *MakeDir; cout<<"\nWhat folder do you wish to check/create?\n"; cin >> path; int length1 = strlen("mkdir "); int length2 = strlen(path); MakeDir = new char [length1 + length2 + 1]; strcpy(MakeDir, "mkdir "); strcat(MakeDir, path); system(MakeDir); if(!MakeDir) { //Let DOS handle it } else { printf("There was no directory. A directory has been created."); } getch(); }
well i spend my time coding a great script for you that WORKS and u go and leave me without a simple "thank you"??? well im never helping u again![]()
You think he hasn't look at it yet?
You coded a program, not a script.
A script is what you give the actors, a program is what you give the audience.![]()
r u saying i did better or worse than a script? lol
u confuse me.
Sorry about thank u late. I really appreciate your program.
I am a beginninger of c++ programming. I expect your further help.
Thanks a lot.
Oh, If I want to check a open a file under a directory on the VC platform, the following statement is correct or not?
fstream file("temp\aa.dat", ios:ut | ios::binary);
Scott