Finding current directory during Visual Studio debugging session?

前端 未结 3 1832
太阳男子
太阳男子 2020-12-17 10:23

How can I find the current directory for a .NET application running under the Visual Studio debugger?

Update 1. To be clear: I don\'t want to change

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 10:33

    The best way is to run the application in WinDbg (the Windows debugger), then attach to the process and run the !handle command. Each open file will have an associated handle. By dumping all the handles for the corresponding process, you will see the corresponding file path.

    Here is an example:

    !handle 0 f process-id
    

    Replace the process-id with the value of your process id. In place of the process id you can also use the process address. If this does not show the file object, then file handle has already been closed. In this case you need to trace the handles. This can be done with the !htrace command.

提交回复
热议问题