// 获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径。
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。
System.Environment.CurrentDirectory // 获取应用程序的当前工作目录。
System.IO.Directory.GetCurrentDirectory() // 获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase // 获取启动了应用程序的可执行文件的路径。
System.Windows.Forms.Application.StartupPath // 获取启动了应用程序的可执行文件的路径及文件名
System.Windows.Forms.Application.ExecutablePath C# WinForm中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别示例如下: private void Frm_Server_Load(object sender, EventArgs e)
{
MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory);
MessageBox.Show(Application.StartupPath );
} 说明: . AppDomain.CurrentDomain.BaseDirectory 返回结果为: D:/mycode/ Application.StartupPath 返回结果为: D:/mycode . Application.StartupPath 只能用于WinForm窗体中,而AppDomain.CurrentDomain.BaseDirectory既可以用于WinForm窗体中,也可以用于类库DLL文件中.

C#中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别的更多相关文章

  1. C#中AppDomain.CurrentDomain.BaseDirectory及各种路径获取方法

    // 获取程序的基目录.System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径,包含文件名System.Diagnostics.Proces ...

  2. AppDomain.CurrentDomain.BaseDirectory是什么

    AppDomain.CurrentDomain.BaseDirectory 是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的属性 ...

  3. AppDomain.CurrentDomain.BaseDirectory

    在winform中的OnPaint事件中,AppDomain.CurrentDomain.BaseDirectory得到的是下面这个路径 C:\Program Files (x86)\Microsof ...

  4. 关于程序路径Path.Combine以及AppDomain.CurrentDomain.BaseDirectory

    关于程序路径 LucenePath:@(System.Configuration.ConfigurationManager.AppSettings["LucenePath"])&l ...

  5. C# AppDomain.CurrentDomain.BaseDirectory

    AppDomain.CurrentDomain.BaseDirectory   是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的 ...

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

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

  7. Directory.GetCurrentDirectory和Application.StartupPath的区别

    System.IO.Directory.GetCurrentDirectory()方法用于获得应用程序当前工作目录.System.Windows.Forms.Application.StartupPa ...

  8. AppDomain.CurrentDomain.BaseDirectory项目目录相关操作

    链接:https://www.cnblogs.com/guolianyu/p/3980971.html 经常用到,每次都百度,所以自己备份一下!

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

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

随机推荐

  1. Linux:ssh端口转发详解

    ssh是个多用途的工具,不仅可以远程登录,还可以搭建socks代理.进行内网穿透,这是利用它的端口转发功能来实现的. 所谓ssh端口转发,就是在ssh连接的基础上,指定 ssh client 或 ss ...

  2. json转实体,json转List实体,json转泛型实体

    1.========================= https://segmentfault.com/a/1190000009523164 package com.thunisoft.maybee ...

  3. Java图形界面设计——substance皮肤

    http://jianweili007-163-com.iteye.com/blog/1141358 ————————————————————————————————————————————————— ...

  4. .NET Framework posters with Namespaces & Types

    Framework is platform containing a huge library of types, methods, classes, etc., cataloged into nam ...

  5. [Python学习]Iterator 和 Generator的学习心得

    [Python学习]Iterator 和 Generator的学习心得 Iterator是迭代器的意思,它的作用是一次产生一个数据项,直到没有为止.这样在 for 循环中就可以对它进行循环处理了.那么 ...

  6. 关于Unity中表面着色器的使用

    写shader其实就是在两个工位顶点shader工位和着色shader工位插入代码,供GPU使用运行 表面着色器四个函数的入口 1:表面着色器包括4个函数: (1): 顶点变换函数; (2): 表面着 ...

  7. Opengl绘制我们的小屋(二)第一人称漫游

    这章我们先讲第一人称漫游的实现.在openTK里,我们用函数Matrix4.LookAt(caram.Eye,caram.Target,Vector3.UnitY)来放置摄像机,其中三个参数分别与摄像 ...

  8. MyBatis错误:Result Maps collection already contains value for novel.storage.mapper.NovelMapper.BaseResultMap

    今天在写项目的时候遇到一个问题如下: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ...

  9. html全选和取消全选JS

    <html> <body> <table border="1"> <tr> <th><input type=&qu ...

  10. vector 用法小例子

    1. vector<int> vec; vec.push_back(1); 2. vector<int> vec(10); vec[0] = 1;