怎样在一个程序集内部写一段代码来知道这个程序集在运行时的路径? 怎样在一个程序集内部写一段代码来知道这个程序集在运行时的路径? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试:using System.Reflection;Response.Write(Assembly.GetExecutingAssembly().GetName().CodeBase); imports system.reflection觉得可以在这个程序集里的一个类中写个方法用反射来获得自己的路径,大概使用的方法就是codebase或者location System.IO.DirectoryInfo sd = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()) ; Environment.CurrentDirectoryApplication.ExecutablePathSystem.Windows.Forms.Application.StartUpPath 用Assembly.GetExecutingAssembly().GetName().CodeBase得到的路径file:///c:/inetpub/wwwroot/ws/WebService1/bin/dbconf.xml无法使用Application.ExecutablePathSystem.Windows.Forms.Application.StartUpPath以上两种方式只适合在CS下使用,BS下就不行System.IO.DirectoryInfo sd = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()) ;在BS下得到的是SYSTEM32路径 MessageBox.Show(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); 用"应用程序域"可以解决using System.AppDomain;......string strAddress = System.AppDomain.CurrentDomain.BaseDirectory.ToString();不知道是不是楼主想要的 感觉这个问题,泡泡的应该是正解,或者System.Reflection.Assembly.GetAssembly( this.GetType() ).Location也可以. 问个关于c#读取Excel后一个简单的问题 WPF中的媒体播放控制 SQL语句命令行参数添加的问题? contextmenustrip定位问题 .net Framework安装失败 c# 二维数组的输入 在使用[分布式事务]的时候出现如下错误 为什么我的vs2005的错误列表存在,但是在它前面有一个“X”(叉)的标志,而不能看到错误信息呢? 迷茫 中,高手指点一下。 在IE中不能打开.vsdisco文件,高手请帮忙 C#上能否实现用窗体控件访问远程数据库 form1的datagrid如何与form2中的dataset绑定
using System.Reflection;Response.Write(Assembly.GetExecutingAssembly().GetName().CodeBase);
觉得可以在这个程序集里的一个类中写个方法用反射来获得自己的路径,大概使用的方法就是codebase或者location
Application.ExecutablePath
System.Windows.Forms.Application.StartUpPath
得到的路径file:///c:/inetpub/wwwroot/ws/WebService1/bin/dbconf.xml无法使用Application.ExecutablePath
System.Windows.Forms.Application.StartUpPath
以上两种方式只适合在CS下使用,BS下就不行System.IO.DirectoryInfo sd = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()) ;
在BS下得到的是SYSTEM32路径
using System.AppDomain;
......string strAddress = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
不知道是不是楼主想要的