【发布时间】:2018-11-23 11:40:45
【问题描述】:
我已阅读此post。我正在尝试在 Windows 服务器上将文件从一个位置移动到另一个位置。运行 F# 程序的用户拥有执行 .Net File.Move 语句的完全权限,我使用使用文件资源管理器登录服务器的同一用户手动测试了此移动。
我想弄清楚我做错了什么。
这里是相关代码,copyOnly就是false。
let rc =
try
if copyOnly then
File.Copy((currentPath + fnam), (destPath + new_file_dest)) |> ignore
logH.WriteLine(generateTimeStamp () + ": " + currentPath + fnam + " copied to " + (new_file_dest + fnam))
else
File.Move((currentPath + fnam), (destPath + new_file_dest)) |> ignore
logH.WriteLine(generateTimeStamp () + ": " + currentPath + fnam + " moved to " + destPath + new_file_dest)
true
with ex ->
logH.WriteLine(generateTimeStamp () + ": " + "An error occrred trying to move or copy " + currentPath + fnam + " to " + (destPath + new_file_dest))
printfn "%A" ex
false
rc
currentPath = \\\\Munis2\\musys_read\\musys\\import_prod\\
fnam = import_arlckbox.007
destPath = \\\\Munis2\\Munis_IC_DataExchange\\archive\\
new_file_dest = import_arlckbox_6132018_15645.007
我很困惑为什么这是一个问题。查看另一篇文章 (post),我确实确保我正在测试的两个用户在所有目录中都具有完全权限,并且我正在将一个文件移动到另一个目录中的另一个文件名。这是参考文章中的一项决议。
我有第二个与错误相关的问题。如果我尝试使用 URL 路径语法调试此问题,如上所述,哪个用户尝试在服务器上执行此任务?
该用户是否与在 Visual Studio 中调试的工作站上的用户相同,或者移动或复制请求是否由默认 Internet 用户处理?
我问这个问题,因为在修复损坏的路径问题后,我仍然无法访问路径被拒绝使用 URL 进行错误调试,但当应用程序直接在服务器上运行时却没有。
【问题讨论】:
-
您能否具体解释一下
currentPath和destPath的值是如何在程序中获取或声明的?我想知道它是否与某种方式的双反斜杠无关(或在musys_read\musys中没有)... -
@ThomasCorbière 我发现了问题。这是一条糟糕的道路。