Visual Studio C# 文件中的工作目录
Visual Studio C# 项目属性中的工作目录到底是什么?
我看到一个项目,我右键单击并转到“属性”,然后转到“调试”选项卡,它显示了代码作者在本地指定文件夹的工作目录机器。我想知道该工作目录意味着什么以及它将在该目录中存储什么类型的文件。
先感谢您。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每个进程都有一个当前的工作目录,所有相对路径都将在其中形成。如果未指定,则此目录是活动应用程序启动的目录。
您可以通过调用以下命令来检查设置的目录:
System.IO.Directory.GetCurrentDirectory();
正如上面 @0xA3 的评论中所述,此设置对您部署的产品没有影响,它仅用于调试。
Every process has a current Working Directory which is where all relative paths will be formed from. If not specified, this directory is the directory in which the active application started.
You can check which directory is set by calling:
System.IO.Directory.GetCurrentDirectory();
As mentioned above in a comment by @0xA3 this setting has no effect to your deployed product, it is is only for debugging.
项目(以及一般的任何 Windows 程序)的工作目录是程序查找其文件的默认位置。例如:我的程序有工作目录 C:\dir 并尝试打开 test.txt,它将在 C:\dir\test.txt 中查找。
因此,每个打开的文件都将相对于工作文件夹打开。
The working directory of a project (and any Windows program in general) is the default place in which a program is looking up it's files. For example: My program has working directory C:\dir and tries to open test.txt, it would look in C:\dir\test.txt.
So every opened file will be opened relative to the working folder.
我认为它不会在那里存储任何内容,除非您在应用程序中添加/编写显式创建文件的代码,或者显式地在应用程序的工作目录中,或者隐式地仅指定文件名而不指定目录。
I think it will store nothing there, unless you add/write code in your application which explicitly creates files, either explicitly in the application's working directory, or implicitly specifying only a filename without specifying a directory at all.