在编写windows服务的时候,怎样获取服务的Exe文件的当前的物理路径?

haisuifeng 2006-08-30 10:08:19
因为我在服务中要去获取一个xml文件,查找一些标志,来判断是否该执行某些操作。还有 就是在某个时间 才能执行某些操作 ,标志和时间都是在xml中可以设置的
...全文
182 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
terry52 2006-08-30
  • 打赏
  • 举报
回复
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
string strBuildPath=a.Location;
int iStrLength=strBuildPath.LastIndexOf("\\");
strBuildPath=strBuildPath.Substring(0,iStrLength+1); //得到安装路径
v192 2006-08-30
  • 打赏
  • 举报
回复
string strPath = Assembly.GetCallingAssembly().Location;

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧