我在访问 ColdFusion 中的映射驱动器时遇到问题。我将 \\server\files\sharing
映射到 z:\
。如果我运行这段代码,它会说该目录存在于完整路径中,但不存在于映射路径中:
<cfscript>
fullPath = "\\server\files\sharing\reports";
mappedPath = "z:\reports";
WriteOutput("fullPath exists: #DirectoryExists(fullPath)#<br/>"); //YES
WriteOutput("mappedPath exists: #DirectoryExists(mappedPath)#"); //NO
</cfscript>
我进行了一些谷歌搜索,发现一些人遇到了同样的问题,但解决方案始终是使用完整路径。 ColdFusion 无法查看或访问映射的驱动器是否有原因?如果是这样,是否有任何解决方法(可能是系统调用以获取映射驱动器的完整路径)?
最佳答案
ColdFusion 无法访问映射驱动器的原因是因为它在 Windows 中作为服务运行。
A service (or any process that is running in a different security context) that must access a remote resource should use the Universal Naming Convention (UNC) name to access the resource.
这是从以下知识库文章中提取的: http://support.microsoft.com/kb/180362
您可以将服务更改为以映射了驱动器的个人用户身份运行(我还没有检查这是否有效,但它可能),但您应该使用 UNC 路径而不是映射的驱动器.
关于windows - 从 ColdFusion 访问映射的网络驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2885303/