这条道路不是合法的形式 [英] The path is not of a legal form

查看:68
本文介绍了这条道路不是合法的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个可以复制"我的文档"的代码。来自其他位置的目录。

Hi, im writing a code that can copy "My Documents" directory from another location.

当我的程序处于调试模式时,所有工作正常,但当我将其切换为发布并创建安装程序时,它无法正常工作。

All is working correctly when my program was on debug mode, but when i switch it to release and create a installer it does not work well.

该程序是Windows服务,我写了一些日志文件,从我观察到的,它在创建目录时停止。

The program is a Windows Services, i write some few log file and from what i observe, it stops when creating a directory.

foreach (string dir in Directory.GetDirectories(_MyDocs, "*.*", SearchOption.AllDirectories))
{            
 Directory.CreateDirectory(dir.Replace(_MyDocs, _backUpDir));
                        WriteLog(dir + " is copied :: " + now.ToString(@"dd\.hh\:mm"));
}

我可以访问另一个位置,并将我的服务帐户设置为LocalSystem。

i have an access to another location and i set my service account as LocalSystem.

推荐答案

在大多数情况下,Windows服务不会从用户的帐户运行。服务通常在服务帐户的上下文中运行,该服务帐户可能没有任何文档。此外,默认情况下,服务不具有网络访问权限,除非它作为域
帐户或使用网络服务(没有文档文件夹或至少包含内容)运行。

Windows services do not run from a user's account in most cases. A service generally runs in the context of a service account which probably doesn't have any documents. Additionally a service won't have network access by default unless it is run as a domain account or using network service (which wouldn't have a document folder, or at least content in it).

是否有特殊原因需要提供服务?

Is there a particular reason this needs to be a service?


这篇关于这条道路不是合法的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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