AppDomain.CurrentDomain.BaseDirectory
在winform中的OnPaint事件中,AppDomain.CurrentDomain.BaseDirectory得到的是下面这个路径
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
Application.ExecutablePath得到的是C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe
file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/us6sa4js01/Accor.Windows.Forms.dll
https://stackoverflow.com/questions/837488/how-can-i-get-the-applications-path-in-a-net-console-application
System.Reflection.Assembly.GetExecutingAssembly().Location1
Combine that with System.IO.Path.GetDirectoryName if all you want is the directory.
1As per Mr.Mindor's comment:
System.Reflection.Assembly.GetExecutingAssembly().Location
returns where the executing assembly is currently located, which may or
may not be where the assembly is located when not executing. In the
case of shadow copying assemblies, you will get a path in a temp
directory.System.Reflection.Assembly.GetExecutingAssembly().CodeBasewill return the 'permanent' path of the assembly.
https://stackoverflow.com/a/841320/3782855
AppDomain.CurrentDomain.BaseDirectory
Don't use this. The BaseDirectory can be set at runtime. It is not guaranteed to be correct (like the accepted answer is).
entryAssembly.GetSatelliteAssembly
System.IO.FileNotFoundException: Could not find file 'file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/dgz79z6i01/en-US/Accor.Windows.Forms.resources.DLL'.
File name: 'file:///C:/Users/clu/AppData/Local/Microsoft/VisualStudio/15.0_74da2886/ProjectAssemblies/dgz79z6i01/en-US/Accor.Windows.Forms.resources.DLL'
AppDomain.CurrentDomain.BaseDirectory的更多相关文章
- C#中AppDomain.CurrentDomain.BaseDirectory及各种路径获取方法
// 获取程序的基目录.System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径,包含文件名System.Diagnostics.Proces ...
- 关于程序路径Path.Combine以及AppDomain.CurrentDomain.BaseDirectory
关于程序路径 LucenePath:@(System.Configuration.ConfigurationManager.AppSettings["LucenePath"])&l ...
- C#中AppDomain.CurrentDomain.BaseDirectory与Application.StartupPath的区别
// 获取程序的基目录. System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径. System.Diagnostics.Process.G ...
- AppDomain.CurrentDomain.BaseDirectory是什么
AppDomain.CurrentDomain.BaseDirectory 是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的属性 ...
- C# AppDomain.CurrentDomain.BaseDirectory
AppDomain.CurrentDomain.BaseDirectory 是获取基目录,它由程序集冲突解决程序用来探测程序集.由显示的路径可以看出,它代表的是程序集所在的目录,它具有读取和写入的 ...
- AppDomain.CurrentDomain.BaseDirectory项目目录相关操作
链接:https://www.cnblogs.com/guolianyu/p/3980971.html 经常用到,每次都百度,所以自己备份一下!
- .Net AppDomain.CurrentDomain.AppendPrivatePath(@"Libs");
今天就说说.Net中通过反射取得某个类型时,我们怎么知道这个类型在硬盘上的哪个角落?比如说,假如我们需要要求服务端动态载入某个数据源,那服务端怎么知道数据源在哪?网上大部分的教程都写着,可以使用Ass ...
- AppDomain.CurrentDomain.GetAssemblies()
AppDomain.CurrentDomain.GetAssemblies() ,获取已加载到此应用程序域的执行上下文中的程序集 解释地址 从微软的解释也可以得知,这个方法只能获取已经加载到此应用程序 ...
- AppDomain.CurrentDomain.AssemblyResolve
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); 参 ...
随机推荐
- SonarQube 平台搭建
1. 前期准备 ① 环境 jdk 1.8 配置(见其他随笔) MySQL 5.7(见其他随笔) ② 工具下载 sonarqube 下载 <链接:https://pan.baidu.com/s/1 ...
- 【BZOJ2320】最多重复子串 调和级数+hash
[BZOJ2320]最多重复子串 Description 一个字符串P的重复数定义为最大的整数R,使得P可以分为R段连续且相同的子串.比方说,“ababab”的重复数为3,“ababa”的重复数为1. ...
- (七)solr7之Terms组件的使用
(七)solr7之Terms组件的使用 Terms组件提供访问索引项的字段和每个词相匹配的文档数量. 这可以用于建立一个自动建议特性或任何其他的特性,而这个terms不是搜索或文档级别的水平.快速检索 ...
- 扩展类 HOW TO EXTEND CLASSES TO MAKE NEW CLASSES IN PYTHON
How to Extend Classes to Make New Classes in Python - dummies https://www.dummies.com/programming/py ...
- minimum viable product
w https://en.wikipedia.org/wiki/Minimum_viable_product
- 关于like %%的优化思路
测试数据:2亿行,被筛选出的数据,3KW多行. 众所周知 like %str%无法走索引,但是我们如果实在是有这种需求要达到like '%str%'的筛选目的,怎么优化好一些呢? 以下是我的一些思考: ...
- 教你管理SQL实例系列(1-15)
全系列转自:51CTO ->jimshu http://jimshu.blog.51cto.com 目录及原本连接如下: 教你管理SQL实例(1)数据库实例 教你管理SQL实例(2)服务启动帐户 ...
- tensorflow 张量的阶、形状、数据类型及None在tensor中表示的意思。
x = tf.placeholder(tf.float32, [None, 784]) x isn't a specific value. It's a placeholder, a value th ...
- 爬虫五 Beautifulsoup模块
一 介绍 Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beautiful Soup会帮你 ...
- C# 截屏函数
截屏函数: using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; ...