VS2008 Project working directory when running in debug through IDE

Started by
3 comments, last by Aardvajk 14 years, 6 months ago
Hi all, I've just set up a new project in VS2008, and part of my program writes to file. When I run the exe as stand alone it puts the file in the exe's directory, but if I run it through the debugger in the IDE it puts it somewhere else. I used to know where to make the necessary change in the project settings, but can't for the life of me find it. I thought it was Project Properties, Configuration Properties, General, Output Directory, but I've changed this and it doesnt seem to have made any difference. Any help would be gratefully appreciated. Thanks, Wibbs
Advertisement
It's Project, Properties, Configuration Properties, Debugging, Working Directory.

Do bear in mind that writing to the application's own directory is something that's not liable to work properly under a non-administrator account (which is the norm on Vista and up) assuming the application is installed in Program Files.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Ah, thanks for the info. Your comment relating to inability to save in certain locations raises another question though. How do you access the (what I assume would be) environment variables that give the paths to the currently logged on users area of the hard drive where they can save stuff?
Take a look at GetEnvironmentVariable(). Users should have (at least) an environment variable named "TEMP" for which you can get a string for the path.

If you're working on a network or other controlled environment, the admin should be able to give you the name of an environment variable (if any) for a logged-on user's area. You then use that function to obtain the path.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

On Windows, you can avoid messing with environment variables and use SHGetKnownFolderPath.

Settings for your game that the game exe needs to write to outside of installation are normally stored in the local app data directory.

This topic is closed to new replies.

Advertisement