Jump to content
  • Advertisement
Sign in to follow this  

[C++/Win32] Incorrect relative path

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

I ask the user for three images and a name before generating a directory tree.

The root appears wherever the last chosen image came from. (If a picked my last image from the Desktop, it pops up there) I use a relative path, but apparently it is considered relative to the last chosen image. (with GetOpenFileName())

If I do not choose an image at all, the app behaves as I expect, where the root appears right by the app. Why does this not remain the case otherwise?

wchar_t buf[MAX_PATH];
wstring path = L".\\";

// Grab game title, which will be used for root path.

// Stack name onto relative path
path += buf;

// Make game directory
if ( !CreateDirectory(path.c_str(),0) ) { /*...*/ }

// Copy resource images into directory
if (bHaveIconPath)


Share this post

Link to post
Share on other sites
GetOpenFileName() changes the applications current working directory. If you don't want that, you can use the OFN_NOCHANGEDIR flag in your OPENFILENAME struct, or call GetCurrentDirectory() before GetOpenFileName() and call SetCurrentDirectory() after.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!