可执行位置之间不同
如果我想获取可执行位置 这个命令有什么不同:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Directory.GetCurrentDirectory();
System.Environment.CurrentDirectory;
有什么不同吗? 它指向不同的位置吗?
if I want to get executable location
what is the different between this command:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Directory.GetCurrentDirectory();
System.Environment.CurrentDirectory;
is there any different ?
is its pointed to different location ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
获取正在执行的程序集的位置。在 ASP.NET 应用程序中,这可能会因系统文件夹中的卷影复制程序集而有所不同。当前执行的程序集的位置可能与宿主进程的位置不同。
获取托管进程的当前工作目录。在大多数情况下,这将是可执行文件所在的目录,但可以使用 SetCurrentDirectory 方法。
启动托管进程的目录。
在桌面应用程序中,所有内容都位于同一文件夹中,这 3 个可能会返回相同的结果。
Gets the location of the executing assembly. In an ASP.NET application this could vary due to shadow copying assemblies in system folders. The location of the currently executing assembly could be different than the location of the hosting process.
Gets the current working directory of the hosting process. In most cases this will be the directory where the executable is located but this working directory could be modified programatically using the SetCurrentDirectory method.
The directory from which the hosting process was started.
In a desktop application where you have everything in the same folder the 3 might return the same.
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
返回指定程序集的文件夹。Directory.GetCurrentDirectory()
获取系统当前目录不带反斜杠。 Directory.GetCurrentDirectory()< code>System.Environment.CurrentDirectory 获取或设置系统当前目录。
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
returns a folder of specified assembly.Directory.GetCurrentDirectory()
gets the system current directory without backslash, according to MSDN. Directory.GetCurrentDirectory()System.Environment.CurrentDirectory
gets or sets system current directory.当前目录是工作目录,它不一定与包含程序集的目录相同。
例如,如果您在命令行上的根 C:\ 驱动器中执行命令“SomeFolder\MyProgram.exe”,则当前目录仍为 C:\
The current directory is the working directory, it's not necessarily the same as the directory that contains your assembly.
For example, if you were on the command line, in the root C:\ drive and did the command "SomeFolder\MyProgram.exe" the current directory would still be C:\