[Win] Executable's working directory?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jonasled
Posts: 34
Joined: Sat Aug 26, 2006 5:08 pm
Location: Sweden
Contact:

[Win] Executable's working directory?

Post by jonasled »

Created an Irrlicht project with Code::Blocks on Windows. When I try to read an XML file located in the same directory as the executable I notice that the working directory is "C:\irrlicht\bin\Win32-gcc", that is, the directory where the Irrlicht.dll is located. On MacOS X I'm pertty sure that the working directory is the application's directory.

That is no problem as long as I can change the working directory, which I can do with irr::io::IFileSystem. However, I don't want to hardcode a path to the executable. How do I get the path to the running executable on Windows? I can't find any method in irr::io::IFileSystem to do that!
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

one question are you running the executeable out of code::blocks? if yes, check at project settings "execution directory"

greets,
halan
jonasled
Posts: 34
Joined: Sat Aug 26, 2006 5:08 pm
Location: Sweden
Contact:

Re: [Win] Executable's working directory?

Post by jonasled »

jonasled wrote:Created an Irrlicht project with Code::Blocks on Windows. When I try to read an XML file located in the same directory as the executable I notice that the working directory is "C:\irrlicht\bin\Win32-gcc", that is, the directory where the Irrlicht.dll is located. On MacOS X I'm pertty sure that the working directory is the application's directory.
I just found out that the problem is that Code::Blocks has a setting called Execution working directory (Project/Target options). The Irrlicht project template sets this value to "C:\irrlicht\bin\Win32-gcc". It has nothing to do with Irrlicht. Irrlicht is, of course, using the executable's directory as the default working directory, just like on Mac.

IMHO the C::B project template should execute the application in the project directory. It makes no sense to use "C:\irrlicht\bin\Win32-gcc"! However, that I should probably report in the CB forum. :wink: I just posted this to save someone else a few hours, which could have been better spent on coding!

It would still be nice to know how to get the path to the running executable in Windows.
jonasled
Posts: 34
Joined: Sat Aug 26, 2006 5:08 pm
Location: Sweden
Contact:

Post by jonasled »

Halan wrote:one question are you running the executeable out of code::blocks? if yes, check at project settings "execution directory"
Thanks Halan, as you can see I just found out on my own. I was writing my post simultaneously. :wink:
Post Reply