Some questions calling a file select dialog using WINAPI

Here’s what I want,
I want to choose some files when I’m building my game.
I click on a ccMenuItem on Cocos2dx’s screen,
there pops up a Windows dialog, letting me choose an image file or more.
Then I reference the path of the file I chose,
to really use the file, maybe creating a sprite.
I think it’s being an easy way to test and arrange data.

And just now I met some problem,
the default directory for resource is set to “Resources/”,
so if I want to open a file in it,
I would directly type the file name,
and open the file.

but I have a file in the “Resources/test/” folder,
so I used WINAPI to pop up a file select dialog,
directed me to the “test” folder,
and choose the file,
then I did some process to get the relative path of it, like “test/test.jpg”,
yet it tells me no such file.

then I tried to only get the name of the file, like “test.jpg”,
Viola…It opens normally.

So that’s really weird,
I mean it seems that the default directory has been somehow changed to another folder due to my selection in the file select dialog.
like " Resources/ " → " Resources/test/"

Here I want to ask,
is there a way to keep the default directory the same,
it’s really confusing me.

Thanks and forgive my poor expression.
Cheers!

you can get current directory when you choose files by open file diadlg,and reset current directory in the end.

using WINAPI,you can use GetCurrentDirectory to get current directory path and SetCurrentDirectory to set current directory. or you can also use C function getcwd andchdir instead. see MSDN libiary…

good luck…

Yong Wen wrote:

you can get current directory when you choose files by open file diadlg,and reset current directory in the end.
>
using WINAPI,you can use GetCurrentDirectory to get current directory path and SetCurrentDirectory to set current directory. or you can also use C function getcwd andchdir instead. see MSDN libiary…
>
good luck…

Sorry for being so late…

Thanks you,
will feedback after I test it.