Net中获取程序集路径
从内存中加载的程序集,无路径
IIS中路径
protected { Response.Write("程序集路径"+System.Reflection.Assembly.GetExecutingAssembly().Location+"<BR/>"); Response.Write("程序域路径"+System.AppDomain.CurrentDomain.BaseDirectory + "<BR/>"); Response.Write("模块路径"+System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName + "<BR/>"); Response.Write("运行时路径"+HttpRuntime.BinDirectory + "<BR/>"); } |
输出
程序集路径C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\test\02a51a22\1e6b2246\assembly\dl3\3464d812\41e5e6a4_2697d301\WebApplication3.dll |
WINFORM中路径
Console.Write("程序集路径" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\r\n"); Console.Write("程序域路径" + System.AppDomain.CurrentDomain.BaseDirectory + "\r\n"); Console.Write("模块路径" + System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName + "\r\n"); Console.Write("运行时路径" + System.Windows.Forms.Application.ExecutablePath+ "\r\n"); |
输出
程序集路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bi n\Debug\ZY.Cloud.Front.GatewayService.exe 程序域路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bi n\Debug\ 模块路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bin\ Debug\ZY.Cloud.Front.GatewayService.exe 运行时路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bi n\Debug\ZY.Cloud.Front.GatewayService.exe |
服务中路径
程序集路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bin\Debug\ZY.Cloud.Front.GatewayService.exe 程序域路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bin\Debug\ 模块路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bin\Debug\ZY.Cloud.Front.GatewayService.exe 运行时路径D:\CodeCard\前置伺服器\综合前置伺服器\ZY.Cloud.Front.GatewayService\bin\Debug\ZY.Cloud.Front.GatewayService.exe |
操作文件时,最好在代码中显示指定路径,毕竟程序集自身的位置是不可控的。推荐使用程序域路径或ExecutablePath
Net中获取程序集路径的更多相关文章
- Java中获取文件路径
Java中获取文件路径 1.实例说明 (1)得到 ClassPath的绝对URI路径 Thread.currentThread().getContextClassLoader().getResourc ...
- Android中获取文件路径的方法总结及对照
最近在写文件存贮,Android中获取文件路径的方法比较多,所以自己也很混乱.找了好几篇博客,发现了以下的路径归纳,记录一下,以备不时之需 Environment.getDataDirectory() ...
- C#中获取程序集版本号的方法
我的方法: string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); 方法一: public v ...
- java代码中获取classpath路径
Javaweb工程中,有时候需要自己手动的去读取classpath下面的配置文件,这里总结一点读取classpath路径的方法,分享一下. 方法一: String path = Test.class. ...
- java web项目中 获取resource路径下的文件路径
public GetResource{ String path = GetResource.class.getClassLoader().getResource("xx/xx.txt&quo ...
- web项目中获取各种路径的方法
~Apple web项目中各种路径的获取 1.可以在servlet的init方法里 String path = getServletContext().getRealPath("/&qu ...
- JAVA类中获取项目路径
在java web项目中获取项目的src/main/resource下的文件路径 当前类名.class.getClassLoader().getResource("/").getP ...
- 【转】c#.net各种应用程序中获取文件路径的方法
控制台应用程序:Environment.CurrentDirectory.Directory.GetCurrentDirectory() windows服务:Environment.CurrentDi ...
- java中获取文件路径的几种方式
http://xyzroundo.iteye.com/blog/1116159关于绝对路径和相对路径: 绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:C:xyz es ...
随机推荐
- [蓝牙前沿应用] 照明即平台 —— 通过蓝牙增强服务提高照明投资回报率(蓝牙MESH、定位AoA、AoD)
1.照明即平台(LAAP) 随着照明设施向LED转型,他们也在利用类似于蓝牙MESH的技术,创建一个可连接的照明平台,作为他们建筑的中枢神经系统.这些系统除了提供先进的照明控制,还建立了一个增强版 ...
- 请求ajax失败的原因(进入到error)
原因: dataType 定义类型和返回类型不一致,我定义的json格式数据. {data:[],num:0} 这种是不规则的字符串,不是严格的json格式 应该改成{"data" ...
- [SQL]LeetCode184. 部门工资最高的员工 | Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [Swift]LeetCode801. 使序列递增的最小交换次数 | Minimum Swaps To Make Sequences Increasing
We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A ...
- 使用Task
http://www.cnblogs.com/Charltsing/p/taskpoolthread.html task默认对线程的调度是逐步增加的,连续多次运行并发线程,会提高占用的线程数,而等若干 ...
- MySQL5.7.25(解压版)Windows下详细的安装过程
大家好,我是浅墨竹染,以下是MySQL5.7.25(解压版)Windows下详细的安装过程 1.首先下载MySQL 推荐去官网上下载MySQL,如果不想找,那么下面就是: Windows32位地址:点 ...
- 微信小程序开发小结
1.点击按钮分享功能: 使用Button组件,设置open-type="share",然后在js文件的onShareAppMessage方法中设置如下: onShareAppMes ...
- ThinkPHP 数据库操作(三) : 查询方法、查询语法、链式操作
查询方法 条件查询方法 where 方法 可以使用 where 方法进行 AND 条件查询: Db::table('think_user') ->where('name','like','%th ...
- SQL注入: with rollup特性
题目名称:因缺思汀的绕过 题目地址:http://www.shiyanbar.com/ctf/1940 1.with rollup: with rollup关键字会在所有记录的最后加上一条记录,该记录 ...
- 【朝花夕拾】Android性能篇之(一)序言及JVM
序言 笔者从事Anroid开发有些年头了,深知掌握Anroid性能优化方面的知识的必要性,这是一个程序员必须修炼的内功.在面试中,它是面试官的挚爱,在工作中,它是代码质量的拦路虎,其重要 ...