File Handling in C++

#include<fstream.h>
#include<conio.h>
#include<direct.h>
void main()
{
clrscr();
mkdir("H:\\Documents\\MyFolder");
ofstream ofile("H:\\Documents\\Myfile.txt");
getch();
}

Neither the mkdir command is working, nor the ofstream statement. If I write
mkdir("H:\\MyFolder");
ofstream ofile("H:\\Myfile.txt");
it works

but

mkdir("H:\\Documents\\MyFolder");
ofstream ofile("H:\\Documents\\Myfile.txt");

Does not work....The Folder Document is already created.. Why??
Last edited on
Please do not post the same thread twice.

http://www.cplusplus.com/forum/general/172597/
I have seen this question in another thread.

Before making a directory you should check if it exist already.
And the file , is supposed to be/opened in that directory ? Because it does not look at this path.
Topic archived. No new replies allowed.