Jump to content
  • Advertisement
Sign in to follow this  
hymerman

Odd problem with relative paths using MSVC.NET

This topic is 4653 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

In my code, I'm using an ifstream to open a tga file for use as a texture. The texture is stored in a folder, 'resources', in the same directory as the executable, and as such I've tried to open the file as "resources/whatever.tga". This is fine if I compile then run the executable through windows, but when I use 'run' through MSVC, the textures come out all white, since for some reason the relative path is treated differently. It works fine if I use an absolute path. So, is there any way to tell MSVC that it's being an idiot? It's obviously forgetting where the exe is, as it's specifically failing when using a relative path. Thanks for yur help, Hymerman

Share this post


Link to post
Share on other sites
Advertisement
MSCV is calling your executable through the following:

Debug/YourExe.exe

So the starting part is not in Debug/ (where I suspect you have your recourses) but ./ (the place of your project).

I think that somewhere in the project options you could change it, for debugging it's under Configuration Properties->Debugging->Working Directory.

Share this post


Link to post
Share on other sites
Ah, excellent, that's solved it. I'd been looking in totally the wrong place :)

For anyone else with this problem, you can change this option per config, so it's not just an option for the Debug build (though it's still in the Debugging settings).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!