System.IO.Directory.GetCurrentDirectory()方法用于获得应用程序当前工作目录。
System.Windows.Forms.Application.StartupPath 获得应用程序的可执行文件的路径,不含文件名

StartupPath 可执行文件固定就不会变,可用于定位
GetCurrentDirectory 不一定是可执行文件所在目录,因启动的位置而变

如有两个程序 C:/A/a.exe 和 C:/B/b.exe
当在 a.exe 中启动 b.exe,System.Diagnostics.Process.Start(@"C:/B/b.exe")
这时,b.exe 中 Directory.GetCurrentDirectory()方法 返回值为“C:/A”,Application.StartupPath 值为“C:/B”
如果直接在 C:/B/ 中启动 b.exe,那么两个值就会一样,都为“C:/B”
这就是 Directory.GetCurrentDirectory 和 Application.StartupPath 的区别

两个意义是不一样的. 
Application.StartupPath是程序的启动目录,这个在程序运行以后,就不会改变了.

Directory.GetCurrentDirectory()是 "当前目录 ",是可以在程序运行时候改变的,用 
Directory.SetCurrentDirectory()就可以改变.

Directory.GetCurrentDirectory()的缺省值是和Application.StartupPath()一样的.

Directory.GetCurrentDirectory和Application.StartupPath的区别的更多相关文章

  1. 【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别

    原文:[C#遗补]获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPa ...

  2. C#中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别

    // 获取程序的基目录. System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径. System.Diagnostics.Process.G ...

  3. 【摘抄】Application.StartupPath和System.Environment.CurrentDirectory的区别

    System.Environment.CurrentDirectory的含义是获取或设置当前工作路径,而Application.StartupPath是获取程序启动路径,表面上看二者没什么区别,但实际 ...

  4. Application.StartupPath和System.Environment.CurrentDirectory的区别

    System.Environment.CurrentDirectory的含义是获取或设置当前工作路径,而Application.StartupPath是获取程序启动路径,表面上看二者没什么区别,但实际 ...

  5. Application.StartupPath同System.Environment.CurrentDirectory区别

    System.Windows.Forms.Application.StartupPath:获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称. System.Environment.Curr ...

  6. System.Environment.CurrentDirectory和Application.StartupPath

    System.Environment.CurrentDirectory的含义是获取或设置当前工作路径,而Application.StartupPath是获取程序启动路径,表面上看二者没什么区别,但实际 ...

  7. 【CITE】当类库项目中无法使用Application.StartupPath的时侯 (注:主要是在进行反射读取文件的时候!!)

    http://jcserver.blog.163.com/blog/static/24044859200851582354135/ 通常我们WinForm编程时,要获取程序当 前运行的文件夹路径会用A ...

  8. 当类库项目中无法使用Application.StartupPath

    通常我们WinForm编程时,要获取程序当前运行的文件夹路径会用Application.StartupPath ,但是Application.StartupPath在编写类库项目时却无法使用,因为我们 ...

  9. Directory.GetCurrentDirectory

    1.一个应用程序中,Directory.GetCurrentDirectory获得的当前工作目录是C:\Windows\System32,这是为什么呢?是如何设置的? 2.在WinXP下:System ...

随机推荐

  1. install ios开发环境

    环境搭建参照下边这个网址: http://itbbs.pconline.com.cn/soft/50602805.html

  2. Mysql基础语法

    mysql SELECT VERSION(), CURRENT_DATE, now();select user(); create database pets;show databases; use ...

  3. CodeForces 451C Predict Outcome of the Game

    Predict Outcome of the Game Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &a ...

  4. 【mark】自己整合的vi/vim命令

    又发现一篇很好的 http://blog.chinaunix.net/uid-16759545-id-4891666.html 又发现一个很好的系列:有空闲要精读一下: http://www.cnbl ...

  5. CentOS最小化安装后,增加GNOME桌面

    背景:下载CentOS 7的安装包后,在虚拟机上安装. 上来就遇到一个问题:提示需要开启intel vt-x. 这个进入BIOS,在CPU的设置中开启即可. 然后怀着兴奋的心情,开始各种下一步的安装, ...

  6. Creating Excel File in Oracle Forms

    Below is the example to create an excel file in Oracle Forms.Pass the Sql query string to the below ...

  7. Hibernate 配置

    package com.shuyinghengxie.doudou; import static org.junit.Assert.*; import org.hibernate.SessionFac ...

  8. Ubuntu中文输入法的添加

    做了一个英文环境的Ubuntu14.04LTS,为了写博客方便,添加了中文输入法,在网上搜寻了一堆方法,最后找到个靠谱的. 1 添加fcitx输入法框架.(在此框架下有各种输入法) sudo add- ...

  9. HNOI2006-公路修建问题(二分答案+并查集)

    公路修建问题 OI island是一个非常漂亮的岛屿,自开发以来,到这儿来旅游的人很多.然而,由于该岛屿刚刚开发不久,所以那里的交通情况还是很糟糕.所以,OIER Association组织成立了,旨 ...

  10. 整理的一些常用的CSS HACK

     ie8以下兼容透明都和支持CSS圆角,这两个都要在服务器上才看到效果,可以本地搭建一个服务器如IIS -pie-background: rgba(255, 255, 255, 0.10);/*IE6 ...