I'm attempting to change the working directory so I can access a png I put in a folder next to the executable. Here's the code:
std::string ExePath() {
char buffer[MAX_PATH];
GetModuleFileName(NULL, buffer, MAX_PATH);
std::string::size_type pos = std::string(buffer).find_last_of("\\/");
return std::string(buffer).substr(0, pos);
}
int main()
{
sf::RenderWindow window(sf::VideoMode(600, 600), "Meatboy experiment");
sf::Texture meatboyT;
if (!meatboyT.loadFromFile("sprites\meatboy.png")) {
std::cout << ExePath() << std::endl;
}
.
.
.
I right click on the project name and click on properties. under debugging, I set the Working directory to $(SolutionDir)$(Configuration)\
.
When I run it the output is c:\users\joseph\source\repos\experiment\x64\Debug
which is two folders deeper than I wanted.
I change the working directory again, to C:\Users\Joseph\source\repos\experiment\experiment
the output is still c:\users\joseph\source\repos\experiment\x64\Debug
. Why?