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

 

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. External Snapshot management

    External Snapshot management Symptom As of at least libvirt 1.1.1, external snapshot support is inco ...

  2. ASP.NET Core Web App应用第三方Bootstrap模板

    引言 作为后端开发来说,前端表示玩不转,我们一般会选择套用一些开源的Bootstrap 模板主题来进行前端设计.那如何套用呢?今天就简单创建一个ASP.NET Core Web MVC 模板项目为例, ...

  3. Win10U盘启动盘制作及Win10系统安装

    准备工具: 1:一个8GU盘 2:下载MediaCreationTool1803.exe程序 及参考文档. 启动盘制作步骤: 1:运行 2:按照截图步骤依次...... 3:制作完成后插拔一下U盘在看 ...

  4. Redis安装及使用详解

    推荐在Linux系统上安装,这里我采用CentOS6: Redis采用3.0.0版本,官网下载即可 由于Redis是C语言编写,需要安装gcc(部分Linux自带gcc) yum install gc ...

  5. ubuntu配置https

    # 重定向 http 到 https server { listen 80; server_name www.domain.com; rewrite ^(.*)$ https://$server_na ...

  6. Java数据结构和算法 - TreeMap源码理解红黑树

    前言 本篇将结合JDK1.6的TreeMap源码,来一起探索红-黑树的奥秘.红黑树是解决二叉搜索树的非平衡问题. 当插入(或者删除)一个新节点时,为了使树保持平衡,必须遵循一定的规则,这个规则就是红- ...

  7. Xamarin.Android 水平对齐与垂直对齐

    水平对齐: 1.LinearLayout添加属性:android:orientation="vertical": 2.元件添加属性:android:layout_gravity=& ...

  8. WebSocket(3)---实现一对一聊天功能

    实现一对一聊天功能 功能介绍:实现A和B单独聊天功能,即A发消息给B只能B接收,同样B向A发消息只能A接收. 本篇博客是在上一遍基础上搭建,上一篇博客地址:[WebSocket]---实现游戏公告功能 ...

  9. Android--加载大分辨率图片到内存

    前言 在使用ImageView显示图片的时候,直接加载一个图片资源到内存中,经常会出现内存溢出的错误,这是因为有些图片的分辨率比较高,把它直接加载到内存中之后,会导致堆内存溢出的问题.这篇博客就来讲解 ...

  10. 【API知识】一种你可能没见过的Controller形式

    前言 这里分享一下我遇到的一个挺有意思的Controller形式,内容涉及@RequestMapping注解的原理. 实际案例 一.基本描述 项目甲中有多个模块,其中就有模块A和B.(这里的模块指的是 ...