Visual studio 2013 change path variable on startup .exe

I put together an exe file in Visual Studio 2013 and it depends on some external files to work. I want to save these files in the same folder as the exe. When I run the .exe by clicking on it in the file explorer, it downloads the files ok. However, when I run it from Visual Studio, it cannot work because the PATH variable does not include the directory with the required files. How do I configure a project to run a program with a modified path variable so that it can access the files correctly?


source to share

1 answer

As far as I understand, you are asking the correct question. I suspect this is a problem with different directories at runtime. In Visual Studio (as far as I know) you have a folder named Debug and a second folder named Release .

You can choose in Visual Studio to run the program in debug or release mode. But you may not have the required files in both directories.

For example:

I made a program that reads "Hello World!" from hello.txt and displays it as a string in the dialog.

If I save the file in the Release directory , the executable works fine outside of the IDE when the executable is run.

However, if you run the application in debug mode through the IDE (Visual Studio), the program will not find the required file. The program looks for a file in the current directory (Debug).

A quick fix for this is to copy the required files to the current working directory. After all, you always have a duplicate set of files in both directories.

I hope I understood you correctly and that my answer helps you. :)



All Articles