在Visual Studio调试会话期间查找当前目录? [英] Finding current directory during Visual Studio debugging session?

查看:183
本文介绍了在Visual Studio调试会话期间查找当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio调试器下运行的.NET应用程序
找到当前目录?



更新1 。要清楚:我不想更改代码
或获取程序本身的信息 - 我只想要
获取有关当前正在
调试的应用程序的信息。



在调试.NET Windows Forms 应用程序(混合VB.NET和
C#)我不知道从哪个位置读取
的XML文件。我预计当前目录是
应用程序的目录。但是,使用Process Explorer,
属性的进程会导致:


D:\Program Files(x86)\ Microsoft Visual Studio 9.0\Common7\


(右键单击进程/属性/选项卡图像/当前目录)。 >

将光标悬停在Process Explorer主视图
的过程中,显示​​了不同的结果(见下面的屏幕截图):


D:\dproj\DTASCall\DTASuperCharge\bin\


什么是正确的?



启动应用程序独立显示预期的
当前目录


D:\dproj\DTASCall\DTASuperCharge\bin\


过程属性窗口。






Process Explorer的注释屏幕截图:



Alt text http://www.pil.sdu.dk/1 /until2039-12-31/PEdiscrepancy_2009-09-02.png

解决方案

在Visual Studio中,在项目的调试选项卡中的设置,您可以根据需要设置工作目录。



要确定代码中的当前工作目录或断点中的即时窗口,尝试

  System.IO.Directory.GetCurrentDirectory()


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 the code or get information in the program itself - I just want to get information about the application currently being debugged.

While debugging a .NET Windows Forms application (mixed VB.NET and C#) I was not sure from which location a XML file was being read from. I expected the current directory to be the application's directory. However, using Process Explorer, properties for the process result in:

D:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\

(right click on process/Properties/tab Image/Current Directory).

Hovering the cursor over the process in the main view of Process Explorer revealed a different result (see below for a screenshot):

D:\dproj\DTASCall\DTASuperCharge\bin\

What is correct?

Starting the application standalone displays the expected current directory,

D:\dproj\DTASCall\DTASuperCharge\bin\

in the Process Explorer process properties window.


Annotated screen-shot of Process Explorer:

Alt text http://www.pil.sdu.dk/1/until2039-12-31/PEdiscrepancy_2009-09-02.png

解决方案

In Visual Studio, under the project's settings in the debug tab, you can set the "Working Directory" if you want.

To determine the current working directory in code or in the immediate window in a breakpoint, try

System.IO.Directory.GetCurrentDirectory()

这篇关于在Visual Studio调试会话期间查找当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆