Windows服务和网络驱动器 [英] Windows service and net drive

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

问题描述

我遇到了Windows XP SP_2的问题


我已经将网络驱动器映射到Z:用于机器用户管理员。


我已经在C#和.NET Framework 1.1中构建了一个Windows服务。这项服务


必须将几个文件复制到这个网络驱动器上,为此,我在机器上使用了de


管理员帐户。


这就是问题:文件和目录类不允许我


访问Z:


有人可以提供帮助吗?


PD:如果我在控制台模式下运行应用程序而不是Windows服务,那么所有


工作正常。


问候和感谢。

解决方案

.NET中不支持映射的驱动器号我知道。


你必须使用UNC路径。


示例:

如果你有一个Z驱动器映射到\\server\share


\


然后在您的服务应用程序中,您将使用\的路径\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ br />

Hi, I''m in troubles with Windows XP SP_2

I''ve mapped a net drive to Z: for the machine user Administrator.

I''ve build a Windows service in C# and .NET Framework 1.1. This service

must copy several files to this net drive and for that, I use de

Administrator account on the machine.

And here is the problem: File and Directory classes don''t allow me to

access Z:

Somebody can help?

P.D.: If I run the app in console mode instead of a Windows service, all

works fine.

Regards and thanks.

解决方案

Mapped drive letters are not supported in .NET as far as I know.

You have to use the UNC path.

Example:
if you have a Z drive mapped to \\server\share


\

then in your service app, you would use the path of \\server\share


\

That''s how I have always done it and it works.


这篇关于Windows服务和网络驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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