Sign in to follow this  

C++ Current Directory

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

Hey How do I get the current directory I'm working in, in C++? I've seen a function called getcurdir() or something like that, which is found in dir.h. I've using Visual Stuio 6 and there is no dir.h? Is there another way to get it? Thanks

Share this post


Link to post
Share on other sites
just use GetModuleFileName from the win32 API

something like:

char lpFilename[255];
memset( lpFilename, 0, 255 );
GetModuleFileName( AfxGetInstanceHandle(),lpFilename, MAX_PATH );

should do it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There is getcwd(buffer,size) in direct.h (win32) or unistd.h (unix)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Current working directory and application paths are not always the same.

Share this post


Link to post
Share on other sites
Thanks

-----
a2ps

Do I have to include anything to use those functions?

------
Anonymous Poster

It says in the reference that direct.h includes dir.h. I don't have dir.h though?

Share this post


Link to post
Share on other sites

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