Game Development Community

Problem When Using EXE To Run Application!

by Valerie Butler · in Technical Issues · 07/17/2009 (10:14 am) · 5 replies

Hi, I have a problem and im not sure whats causing it! I have a C++ application which creates a txt file and writes information out to that text file and then my game reads from this file! I am using Visual Studio to compile and run both the application and the game engine! Everything works fine when I run it from inside visual studio, but when I try to run the application which sends the data to the file, by just clicking on the exe in the output folder, it wont output for some reason! It runs fine inside visual studio! Has anyone else had a problem with running an application outside visual studio! I have tried to rebuild it multiple times but to no avail! If anybody could shine any light on this matter I would be very greatful! Thanks!

#1
07/18/2009 (11:19 pm)
Note that the working directory is different when running from VIsual Studio and when double-clicking the application. When you run from VS the working directory is the project directory (where your source files are) and not the output directory (where the EXE is). If you use a relative path name for the output file, it could be a difference.
#2
07/21/2009 (1:05 pm)
Thanks for the reply, sorry for delay also, I was away for the past few days! How do you mean use a relative path name for the output file? The current output directory is a folder called bin_dbg and the output file is set to "$(OutDir)\$(ProjectName).exe". Thank you!
#3
07/22/2009 (12:22 am)
Sorry for the confusing terms. I referred to the txt file you are writing also as an output file. You can also check (in your program) the return values from the file open and file write functions to understand if they work correctly, even when you don't run inside a debugger..
#4
07/22/2009 (4:54 am)
No problem, I tried changing the output directory to where the the text files are, and that didnt work! Is this what you meant or should I try something different? Thank you!
#5
07/22/2009 (8:08 am)
Its ok, I solved it! Thanks Danny, you were right, running it visual studio I was using a certain path to put the files in and when using the exe, the path had to be changed to make it relative to the location of my exe! This was what you were suggesting first but it took a while for me to cop it! Works fine now! Thanks! :-)