[C++/Win32] Incorrect relative path

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

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 pathpath += buf;// Make game directoryif ( !CreateDirectory(path.c_str(),0) ) { /*...*/ }// Copy resource images into directoryif (bHaveIconPath){     GetWindowTextW(hIconPath,buf,MAX_PATH);     CopyFile(buf,(path+L"\\icon.png").c_str(),FALSE);}//...

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 on other sites
Thank you, Steve. Sorry I did not check the docs on that one. The tool is finished now. [smile]

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• Forum Statistics

• Total Topics
632651
• Total Posts
3007648
• Who's Online (See full list)

There are no registered users currently online

×