无法从Windows服务访问驱动器映射的网络共享文件 [英] Cannot access files on drive mapped network share from a Windows service

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

问题描述

我必须映射到一个驱动器号,这是从Windows资源管理器访问,在命令提示符下,以及从我的WinForms没有问题的应用程序的网络共享文件夹。它也可以使用UNC路径我的Windows服务访问。

I have a network shared folder mapped to a drive letter, which is accessible from Windows Explorer, from the command prompt as well as from my WinForms application without problem. It is also accessible from my Windows service using a UNC path.

然而,当我试图用Windows服务映射驱动器号来访问网络位置,访问失败。 Windows服务被配置为使用我个人的登录帐户凭据,这是在所有上述情况相同。我是一个管理员。

However, when I attempt to access this network location using a mapped drive letter from the Windows service, access fails. The Windows service is configured to use my personal "Log On" account credentials, which is the same in all the above cases. I am an administrator.

许多客户现场使用的驱动器号的网络共享,我总是无法控制这一点,并强迫他们,而不是指定的UNC路径。我需要能够从Windows服务访问使用的驱动器号网络共享。

Many customer sites utilize drive letters for network shares and I cannot always control this and force them to specify UNC paths instead. I need to be able to access network shares using drive letters from a Windows service.

什么我需要做的设置我的Windows服务,以便它可以访问网络共享映射到驱动器号的文件夹?我的Windows服务是用C#

What do I need to do to set up my Windows service, so that it can access network shared folders that are mapped to drive letters? My Windows service is written in C#.

推荐答案

对不起; 你不能从Windows服务访问映射驱动器。由于盛的建议,您可以使用UI过程从映射驱动器获得的UNC路径,然后传递到服务,必须使用UNC路径。

Sorry; you can't access mapped drives from Windows services. As Sheng suggested, you can use a UI process to get the UNC path from a mapped drive and then pass this to the service, which must use the UNC path.

这篇关于无法从Windows服务访问驱动器映射的网络共享文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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