Solved

Changing directories

Posted on 2004-05-01
2
305 Views
Last Modified: 2010-04-01

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).
0
Comment
Question by:jewee
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
ID: 10969116
What does 'chdir()' return? E.g.

if ( -1 == chdir ( "/temp/dir")) perror ( "invalid path for chdir");
0
 

Author Comment

by:jewee
ID: 10969169
Unbelievable, apparently, when I used chdir, i included another / like this "/temp/dir/"

thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now