.Net Windows服务程序中获取安装程序所在目录

若用语句System.Environment.CurrentDirectory则返回的路径为C:WINDOWSsystem32不能正确指向安装程序所在路径,改用如下代码即可实现。

strings trAssemblyFilePath = Assembly.GetExecutingAssembly().Location;

string strAssemblyDirPath = Path.GetDirectoryName(strAssemblyFilePath);

string  strPath = strAssemblyDirPath + \Log;

引用自:http://www.cnblogs.com/xiaofengfeng/archive/2011/10/27/2226325.html

Top
收藏
关注
评论
原文地址:https://www.cnblogs.com/liuyu7177/p/3222718.html