Changing directories


In my code, I have to change directories but chdir does not work.  How do I go about setting the directory?

One more thing too...If you want to start polling in one directory,
Directory 1: /temp/dir1

I am getting a file from that directory and wanting to move it to another directory, /temp/dir2/  
In that directory, I want to run a tool which generates another file but I want to set the directory to dir2 for the duration of the program.  How would I do that?  (Linux platform).
jeweeAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
What does 'chdir()' return? E.g.

if ( -1 == chdir ( "/temp/dir")) perror ( "invalid path for chdir");
0
 
jeweeAuthor Commented:
Unbelievable, apparently, when I used chdir, i included another / like this "/temp/dir/"

thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.