本文介绍了帮助!关于C#Windows Services创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友:
谢谢您的关注.
我已经使用Microsoft Visual Studio 2005创建了Windows Services应用程序.我的要求是启动Windows Services时创建文件夹",我的代码如下:
Hi,Friends:
Thank you for look here.
I have create a windows services application with microsoft visual studio 2005. my request is ''create a folder when i start this windows services'' and my code is like this:
protected override void OnStart(string[] args)
{
//// TODO: Add code here to start your service.
string path = @"C:\Program Files\ABC\SystemLogs\";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
安装此服务后,我无法启动它.在Windows事件日志中,出现错误"System.UnauthorizedAccessException ...".
如果您有什么想法可以帮助我,非常感谢. :)
after install this service,i can''t start it.and in windows event log get the error "System.UnauthorizedAccessException ...".
if you have some idea can help me,thank you very much. :)
推荐答案
这篇关于帮助!关于C#Windows Services创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!