C#Windows服务终止 [英] C# windows service quoestion

查看:137
本文介绍了C#Windows服务终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我提供了一项服务,该服务从.xml文件读取需要ping的内容,然后ping该位置.我不明白的是为什么要使服务正常工作,我需要将xml文件放入system32中,否则它将看不到xml文件.

这是我指定xml所在的代码行.

XmlTextReader reader =新的XmlTextReader("C:\\ Program Files \ IDE3 Monitoring Service \ KonfiguracijaKlijenta.xml");

提前tnx

Hi,

I made a service that reads from an .xml file what it needs to ping and then pings that location. What i dont understand is why for service to work i need to put xml file into system32 otherwise it cant see the xml file.

this is the line of code where i specified where the xml resides.

XmlTextReader reader = new XmlTextReader("C:\\Program Files\IDE3 Monitoring Service\KonfiguracijaKlijenta.xml");

tnx in advance

推荐答案

我需要将xml文件放入system32,否则无法看到xml文件
听起来像是安全权限的事情.尝试将其放在其他驱动器中,并允许安全性权限中的所有人"进行验证.

如果有任何错误,请发布错误.
i need to put xml file into system32 otherwise it cant see the xml file
Sounds like security permissions thing. Try putting it in your other drive or so and allow ''everyone'' in security permissions to verify.

Post the error if any you get.


tnx我会尝试的,但是我还有另一个问题..

我如何指定该服务在用户安装该服务的位置查找我的.xml文件,所以我不需要对路径进行硬编码?

例如..用户在c:\ program files \ blabla中安装此服务..那里会有我的配置xml文件..我需要的是告诉程序自动在该位置查找xml,以便其读取它需要的信息是因为xml文件将位于该安装文件夹中.如何在用户不知道用户选择的路径的情况下将用户选择安装服务的路径传递给xml文本阅读器?
tnx i''ll try that but i have another question..

how can i specify that service looks for my .xml file in the location where user installed this service so i dont need to hard code the path?

for example..user installs this service in c:\program files\blabla..in there there will be my configuration xml file..and what i need is to tell the program to automaticly look for xml in that location for it to read the info it needs becouse the xml file will be in that installation folder..how to pass the path where user choosed to install service to the xml text reader without me knowing what path user choosed?


您应该将数据文件放入相应的用户特定文件夹中.
You should be putting the data file into the appropriate user-specific folder.


这篇关于C#Windows服务终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆