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 ...
随机推荐
- 解决idea导入项目后依赖报错问题
1.在idea首页 Confige-->setting-->build,execution,deployment-->buildTool-->maven-->work o ...
- JS实现数组去重方法大总结
js数组根据对象中的元素去重: var arr2 = [ { name: "name1", num: "1" }, { name: "name2&qu ...
- [Swift]LeetCode563. 二叉树的坡度 | Binary Tree Tilt
Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the ab ...
- React 中 Link 和 NavLink 组件 activeClassName、activeStyle 属性不生效的问题
首先 导航链接应该使用 NavLink 而不再是 Link NavLink 使用方法见 https://github.com/ReactTraining/react-router/blob/mas ...
- Synchronized的那些事
在上一篇博客中,我"蜻蜓点水"般的介绍了下Java内存模型,在这一篇博客,我将带着大家看下Synchronized关键字的那些事,其实把Synchronized关键字放到上一篇博客 ...
- 剖析项目多个logback配置(下)
来源:http://www.cnblogs.com/guozp/p/5973038.html 上篇大概描述了logback的加载顺序以及加载的源码,本篇将分析如果在你的Maven或者其他多模块的项目中 ...
- nfs服务启动失败:Failed to start NFS status monitor for NFSv2/3 locking..
今天碰到个问题,服务器重启后,nfs服务就启动不了了,关闭都关不了.查看系统日志报下面的错: Aug 10 17:08:53 prod-r3-slt-s-01 systemd: Started Pre ...
- [MySQL]支持 emoji(字符集问题)
问题的根源 主要问题就是在字符集,一般解决这种问题都是靠试验.我实验了一通,得出的结论和大家分享一下(如有错误,还望指正): 数据库的字符集 数据库连接的字符集 配置方法 设置数据库的字符集为utf8 ...
- python:数据库连接操作入门
模块 import pymssql,pyodbc 模块说明 pymssql和pyodbc模块都是常用的用于SQL Server.MySQL等数据库的连接及操作的模块,当然一些其他的模块也可以进行相应的 ...
- Chapter 4 Invitations——14
"Hi, Bella." “你好,Bella” "What's up?" I said as I was unlocking the door. “怎么了?” ...