当前位置: 代码迷 >> 综合 >> WIN服务 winservice 中 获取安装文件所在路径
  详细解决方案

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

热度:53   发布时间:2024-01-21 22:49:50.0

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

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

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

 

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

 

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