帮助!关于C#Windows Services创建文件夹 [英] Help!About C# Windows Services Create Folder

查看:316
本文介绍了帮助!关于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. :)

推荐答案

运行服务的帐户可能没有权限在提到的位置创建文件夹.检查并更新用户的权限.
The account under which your service is running might not be having rights to create the folders at the mentioned location. Check and update the rights for the user.


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

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