0

In my VS project I am defining the path to a file that I want to read relative to the location of the compiled executable of my application with cd..//..// and so on. This does work perfectly inside debug and release configurations in Visual Studio. However, if I directly run the generated executable, the file path does not point to the actual file. It seems like cd is something else, but I am not sure what it actually points to.

How should I define my path to a file relative from the generated executable?

Lemonbonbon
  • 686
  • 5
  • 25
  • No, the attached solution does not work for me. `GetModuleFileName` returns the `C` directory, which is not the location of the executable. I need to know the exe location. – Lemonbonbon Jun 16 '22 at 17:15
  • Project > Properties > Debugging, note the value of the Working Directory setting. That is not where the .exe file is stored. Change it to $(OutDir) and it now behaves the same way it does when you run the program from the command prompt. – Hans Passant Jun 16 '22 at 17:23

0 Answers0