Sign in to follow this  

C++ fileio accessing subdirectories

This topic is 4243 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

my project directory is getting pretty bloated and im trying to break it down into seperate directories for my media etc, currently im accessing my files like so char* filename = "objList.dat"; which seems to default to the current directory but when i try any of the following to try and access a sub dir it just doesnt load "/media/objList.dat"; "//media//objList.dat"; "\\media\\objList.dat"; im sure this is very simple, but still its doing my head in thanks

Share this post


Link to post
Share on other sites
Try making the path complete by adding a dot, indicating to start from the curren directory:

"./media/objList.dat"; (for unix-based systems, works on windows as well)
".//media//objList.dat"; (makes no sense, '/' is not an escape character)
".\\media\\objList.dat"; (for windows, double '\\' because '\' is an escape character)

Illco

Share this post


Link to post
Share on other sites
Quote:
Original post by Illco
Try making the path complete by adding a dot, indicating to start from the curren directory:

"./media/objList.dat"; (for unix-based systems, works on windows as well)
".//media//objList.dat"; (makes no sense, '/' is not an escape character)
".\\media\\objList.dat"; (for windows, double '\\' because '\' is an escape character)

Illco

Yes, that will work, but you can also remove the slash:

"media/objList.dat";
"media\\objList.dat";

You can use whatever you like - both should work fine.

Share this post


Link to post
Share on other sites

This topic is 4243 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this