14

What exactly is Working Directory in the properties of Visual Studio C# project.

I have see a project where I right click and go to Properties and then I go to Debug tab, it shows me Working Directory where Author of the code has specified folder in local machine. I want to know what does that working directory means and what kinds of file will it store in that directory.

Thank you in advance.

4

3 回答 3

10

每个进程都有一个当前工作目录,所有相对路径都将从该目录形成。如果未指定,则此目录是活动应用程序启动的目录。

您可以通过调用检查设置了哪个目录:

System.IO.Directory.GetCurrentDirectory();

正如上面@0xA3 的评论中提到的,此设置对您部署的产品没有影响,它仅用于调试。

于 2010-09-09T14:09:50.787 回答
5

项目的工作目录(以及一般的任何 Windows 程序)是程序查找文件的默认位置。例如:我的程序有工作目录 C:\dir 并尝试打开 test.txt,它会在 C:\dir\test.txt 中查找。

因此,每个打开的文件都将相对于工作文件夹打开。

于 2010-09-09T14:10:32.463 回答
1

我认为它不会在那里存储任何内容,除非您在应用程序中添加/编写显式创建文件的代码,或者在应用程序的工作目录中显式创建文件,或者在根本不指定目录的情况下仅隐式指定文件名。

于 2010-09-09T14:14:22.753 回答