从 C# 中的 windows 服务访问 NFS 驱动器
Accessing to NFS drive from windows service in C#
我用 .net core 3.1 写了一个 windows 服务。此服务应访问 NFS 驱动器但抛出以下异常。
System.IO.DirectoryNotFoundException: Could not find a part of the
path 'Z:...\sample.txt'.
我已使用登录系统(windows 服务器)的同一用户安装此服务。另外,我写了一个Console应用程序进行测试,console应用程序可以访问NFS驱动器。
为什么我可以通过控制台和同一个用户访问,但是在windows服务中,我无法访问NFS驱动器。
如您在此处看到的那样有道理:Map a network drive to be used by a service 和
https://superuser.com/questions/650025/how-to-access-mapped-directory-from-a-windows-service
为什么?
persistent drive mappings are only restored on an interactive logon, which services typically don't perform.
我的建议是使用符号 link。似乎更简单的解决方案
mklink /D C:\myLink \127.0.0.1\c$
我用 .net core 3.1 写了一个 windows 服务。此服务应访问 NFS 驱动器但抛出以下异常。
System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:...\sample.txt'.
我已使用登录系统(windows 服务器)的同一用户安装此服务。另外,我写了一个Console应用程序进行测试,console应用程序可以访问NFS驱动器。
为什么我可以通过控制台和同一个用户访问,但是在windows服务中,我无法访问NFS驱动器。
如您在此处看到的那样有道理:Map a network drive to be used by a service 和 https://superuser.com/questions/650025/how-to-access-mapped-directory-from-a-windows-service
为什么?
persistent drive mappings are only restored on an interactive logon, which services typically don't perform.
我的建议是使用符号 link。似乎更简单的解决方案
mklink /D C:\myLink \127.0.0.1\c$