Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i open a windows folder using c??

Status
Not open for further replies.

goingforgold

Programmer
Jun 30, 2001
4
US
in my program i'm using about 10 text files to store results. The program creates these files. I would now like the program to create a windows folder into which i could put the text files....how do you do this.??

thanks
 
What I understand you are using c++ in windows environment. You want to create a folder to create those files.

To create folder use CreateDirectory() function.
While writing you can use SetCurrentDirectory.

Hope it works...

Navin
 
sorry, but i didn't really understand that very well??!!!

what arguments do you have to put in to the createdirectory function????
 
you will want to look into mkdir and chdir.

Suppose you want to save to C:\Temp\Data

if(!chdir("C:\\Temp"))
{
mkdir("C:\\Temp");
chdir("C:\\Temp");
}

// current location C:\TEmp

if(!chdir("C:\\Temp\\Data"))
{
mkdir("C:\\Temp\\Data");
chdir("C:\\Temp\\Data");
}

Now the directory exists for you to write files to

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top