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()
.Location
1
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().CodeBase
will 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); 参 ...
随机推荐
- JavaScript API 设计准则
好的 API 设计:在自描述的同时,达到抽象的目标. 设计良好的 API ,开发者可以快速上手,没必要经常抱着手册和文档,也没必要频繁光顾技术支持社区. 流畅的接口 方法链:流畅易读,更易理解 //常 ...
- c++包含头文件好还是重新定义好
A.h struct A { int a; int b; }; B.cpp 在B.cpp里面用到这个结构体 有两种方法 .自己定义一个一模一样的结构体 struct A { }; .包含A.h头文件 ...
- POJ1751 Highways
题目链接 http://poj.org/problem?id=1751 题目大意:输入n:然后给你n个点的坐标(任意两点之间皆可达):输入m:接下来m行每行输入两个整数x,y表示 点x与点y 已 ...
- 【转】PowerVM 的主要组成部分及概念
PowerVM 是在基于 IBM POWER 处理器的硬件平台上提供的具有行业领先水平的虚拟化技术家族.它是 IBM Power System 虚拟化技术全新和统一的品牌(逻辑分区,微分区,Hyper ...
- QCache 缓存(模板类,类似于map,逻辑意义上的缓存,方便管理,和CPU缓存无关。自动获得被插入对象的所有权,超过一定数量就会抛弃某些值)
在软件开发中,我们经常需要在内存中存储一些临时数据用于后续相关计算.我们一般把这些数据存储到某个数组里,或者STL中的某个合适的容器中.其实,在Qt中直接为我们提供了一个QCache类专用于这种需求. ...
- Django 之 CBV & FBV
FBV FBV(function base views) 就是在视图里使用函数处理请求. 在之前django随笔中,一直使用的是这种方式,不再赘述. CBV CBV(class base views) ...
- Apache JServ Protocol (AJP)
The Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web serv ...
- springboot整合Ehcache
首先引入maven包: <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- 判断点是否在区域的python实现(射线法)
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2018-10-07 15:49:37 # @Author : Sheldon (thi ...
- 交换机/路由器上的 S口 F口 E口
S口是serial接口的意思,也叫高速异步串口,主要是连接广域网的V.35线缆用的,说白了就是路由器和路由器连接时候用的,可以用命令设置带宽,一般也就在10M.8M左右.F口是FastEthernet ...