WIN服务 winservice 中 获取安装文件所在路径

来源:互联网 发布:电子地图基本数据信息 编辑:程序博客网 时间:2024/04/29 00:26

如果要获取 服务的安装路径

System.Environment.CurrentDirectory则返回的路径为C:\WINDOWS\system32

上面是服务的路径,不是安装路径

 

//获取当前目录
            string strAssemblyFilePath = Assembly.GetExecutingAssembly().Location;
            string AppPath = Path.GetDirectoryName(strAssemblyFilePath)+ "\\UpdateConfig.xml";

 

这样获取就是正确的安装路径