Jump to content
  • Advertisement
Sign in to follow this  
zyrolasting

[C++/Win32] Incorrect relative path

This topic is 2905 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.
GetWindowTextW(gEditBox,buf,MAX_PATH);

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

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

// Copy resource images into directory
if (bHaveIconPath)
{
GetWindowTextW(hIconPath,buf,MAX_PATH);
CopyFile(buf,(path+L"\\icon.png").c_str(),FALSE);
}

//...

Share this post


Link to post
Share on other sites
Advertisement
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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!