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

 

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

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

posted on 2013-07-29 13:06  六欲  阅读(269)  评论(0编辑  收藏  举报

导航