从内存中加载的程序集,无路径

 

IIS中路径

protected
void Page_Load(object sender, EventArgs e)

{

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
程序域路径d:\Users\zwx\Documents\visual studio 2015\Projects\WebApplication3\WebApplication3\
模块路径c:\windows\system32\inetsrv\w3wp.exe
运行时路径d:\Users\zwx\Documents\visual studio 2015\Projects\WebApplication3\WebApplication3\bin\

 

 

 

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中获取程序集路径的更多相关文章

  1. Java中获取文件路径

    Java中获取文件路径 1.实例说明 (1)得到 ClassPath的绝对URI路径 Thread.currentThread().getContextClassLoader().getResourc ...

  2. Android中获取文件路径的方法总结及对照

    最近在写文件存贮,Android中获取文件路径的方法比较多,所以自己也很混乱.找了好几篇博客,发现了以下的路径归纳,记录一下,以备不时之需 Environment.getDataDirectory() ...

  3. C#中获取程序集版本号的方法

    我的方法: string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();   方法一: public v ...

  4. java代码中获取classpath路径

    Javaweb工程中,有时候需要自己手动的去读取classpath下面的配置文件,这里总结一点读取classpath路径的方法,分享一下. 方法一: String path = Test.class. ...

  5. java web项目中 获取resource路径下的文件路径

    public GetResource{ String path = GetResource.class.getClassLoader().getResource("xx/xx.txt&quo ...

  6. web项目中获取各种路径的方法

    ~Apple   web项目中各种路径的获取 1.可以在servlet的init方法里 String path = getServletContext().getRealPath("/&qu ...

  7. JAVA类中获取项目路径

    在java web项目中获取项目的src/main/resource下的文件路径 当前类名.class.getClassLoader().getResource("/").getP ...

  8. 【转】c#.net各种应用程序中获取文件路径的方法

    控制台应用程序:Environment.CurrentDirectory.Directory.GetCurrentDirectory() windows服务:Environment.CurrentDi ...

  9. java中获取文件路径的几种方式

    http://xyzroundo.iteye.com/blog/1116159关于绝对路径和相对路径: 绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:C:xyz es ...

随机推荐

  1. Java中的队列同步器AQS

    一.AQS概念 1.队列同步器是用来构建锁或者其他同步组件的基础框架,使用一个int型变量代表同步状态,通过内置的队列来完成线程的排队工作. 2.下面是JDK8文档中对于AQS的部分介绍 public ...

  2. emWin录音机,含uCOS-III和FreeRTOS两个版本

    第12期:录音机配套例子:V6-921_STemWin提高篇实验_录音机(uCOS-III)V6-922_STemWin提高篇实验_录音机(FreeRTOS) 例程下载地址: http://forum ...

  3. github pages + Hexo + node.js 搭建属于自己的个人博客网站

     之前我写过一篇用Github实现个人主页的博客:https://www.cnblogs.com/tu-0718/p/8081288.html   后来看到某个大佬写的文章:[5分钟 0元搭建个人独立 ...

  4. [Swift]LeetCode70. 爬楼梯 | Climbing Stairs

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  5. [Java]LeetCode278. 第一个错误的版本 | First Bad Version

    You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...

  6. [Swift]LeetCode689. 三个无重叠子数组的最大和 | Maximum Sum of 3 Non-Overlapping Subarrays

    In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. E ...

  7. [Swift]LeetCode957. N天后的牢房 | Prison Cells After N Days

    There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the ...

  8. ubuntu18下安装docker

    1.通过指令检查linux内核 uname -a  可以看到大于3.10版本 2.检查是否存在对应目录 ls -l /sys/class/misc/device-mapper 3. apt-get指令 ...

  9. CKEditor上传视频(java)

    CKEditor上传视频 CKEditor批量上传图片flvplayer.swf播放器CKEditor整合包(v4.6.1) ------------------------------------ ...

  10. 搭建自己的hexo博客

    这是我最近用hexo搭建的个人博客,欢迎来参观留言,以下是我创建这个hexo的一步步步骤,欢迎指正! 我的博客 参考自 潘柏信的博客;CnFeat 主题参考这里 pacman; 主题选自这里 hexa ...