Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Raistlin Majere

Really silly question

This topic is 5269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am having troubles to create a program that can go to a specific folder and read and writes files in there, how could I do that (the executable is in another folder). I am using c and opengl and glut library. Any idea, thanks, Raistlin.

Share this post


Link to post
Share on other sites
Advertisement
the file name you pass as an argument can be a relative or absolute path

so if you open the file "foo" it is foo in your folder
but if you open "bar/foo" it opens the file foo in the bar folder in your folder

as an absolute path, if you open "/home/luser/foo" that is the file foo in the folder /home/luser
for a win32 example, you could open the file "c:\bar\foo"

Share this post


Link to post
Share on other sites
As Raven said, files can be opened with relative an absolute paths. But if your really want to go to a specific folder for some reason, then you must use _chdir (MSVC specific as far as i know). For example:

_getcwd(saveoldpath, lengthofoldpath);
_chdir(yourpath);
// do your work
_chdir(saveoldpath); // switch back

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!