Find out Current Directory during Visual Studio C++ Debug session
Asked Answered
D

1

9

I'm debugging C++ native application on Visual Studio 2015.
After stopping on a breakpoint, I would like to know the Current Directory. (It could have changed during the execution before stopping on that breakpoint).

On .NET debugging it is possible through the immediate window. This does not work when debugging C++ native application.

Is there a way I could find out the Current Directory when debugging C++ native application?

To make it clear - I don't want to change and build my code again. I would like to find this out in the debugger (watch window, command/immediate window etc.)

Dreibund answered 3/12, 2015 at 8:38 Comment(4)
The $env pseudovariable in a watch window (for the nicer viewer) could help, although it's not a direct answer.Hayrick
@Hayrick from a brief pass over the environment variables presented in $env, I could not find anything that reveals the Current Directory.Dreibund
It typically contains entries like =C:= at the very beginning, which contain the simulated per-drive current directories. Unfortunately, this only works reliably in a console app. Those entries can be slightly different (or not present at all) in non-console windows apps, depending on other things that the app is doing. That's why I don't consider this an answer, but I thought it was worth mentioning. Adding a pseudovariable for this could be a nice suggestion to make to the VS team.Hayrick
@Hayrick Good idea. I've added a new suggestion.Dreibund
M
4

In Visual Studio 2015 there is a "C# Interactive" Window. You can use the C# command from .NET solution you presented to get the current directory while debugging Native project. View -> Other Windows -> C# Interactive

If you don't see this option you might want to reinstall VS2015 with C#/.NET components. (I have selected all C# related components during the install.)

Mintamintage answered 22/8, 2017 at 20:22 Comment(1)
For me, this is capable of printing a working directory, but it's not actually the working directory of the process.Hensley

© 2022 - 2024 — McMap. All rights reserved.