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 ...
随机推荐
- Javascript高级编程学习笔记(92)—— Canvas(9) 渐变
渐变 渐变由 canvasGradient 实例表示 要创建一个渐变对象需要调用 createLinearGradient() 方法 该方法接收四个参数: 起点的x坐标 起点的y坐标 终点的x坐标 终 ...
- [Swift]LeetCode17. 电话号码的字母组合 | Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...
- [Swift]LeetCode214. 最短回文串 | Shortest Palindrome
Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. ...
- [Swift]LeetCode980. 不同路径 III | Unique Paths III
On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square. There is e ...
- spring-cloud-sleuth+zipkin源码探究
1. spring-cloud-sleuth+zipkin源码探究 1.1. 前言 粗略看了下spring cloud sleuth core源码,发现内容真的有点多,它支持了很多类型的链路追踪, ...
- H5 页面调试小帮手-UC 开发者工具
调试web页面难 接触过app自动化的同学都比较清楚,如果想要对web应用或者Hybrid应用进行调试时(获取页面元素信息等等),必定绕不开的就是chrome浏览器的inspect功能了:在chrom ...
- iOS学习——Quartz2D学习之UIKit绘制
iOS学习——Quartz2D学习之UIKit绘制 1.总述 在IOS中绘图技术主要包括:UIKit.Quartz 2D.Core Animation和OpenGL ES.其中Core Animati ...
- Xamarin.Android多窗口传值【1】
这种非常常见的场景我觉得大家都遇到过,那么我么可以通过Activity进行编码传值. using System.Text; using System; using Android.App; using ...
- Android Studio升级到3.1.4后打开旧项目警告:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
现象截图 问题原因&解决方案 在build.gralde中,对Android开发过程中突破的方法数的限制,做了如下解决配置: dexOptions { incremental true jav ...
- Gulp介绍与入门实践
Gulp,一个基于流的构建工具. 这是自己写的一个构建的demo,只是一个纯演示的示例,并没有完成什么项目工作.下面根据这个demo介绍一下Gulp. 上代码: gulpfile.js 'use st ...