Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net F拒绝访问该路径#_.net_File_F# - Fatal编程技术网

.net F拒绝访问该路径#

.net F拒绝访问该路径#,.net,file,f#,.net,File,F#,我读过这个。我正在尝试在Windows服务器上将文件从一个位置移动到另一个位置。运行F#程序的用户拥有执行.Net File.Move语句的完全权限,我使用使用File Explorer登录到服务器的同一用户手动测试了此移动 我正在努力找出我做错了什么 这是相关代码,copyOnly是false let rc = try if copyOnly then File.Copy((currentPath + fnam), (destPath + new_fi

我读过这个。我正在尝试在Windows服务器上将文件从一个位置移动到另一个位置。运行F#程序的用户拥有执行.Net File.Move语句的完全权限,我使用使用File Explorer登录到服务器的同一用户手动测试了此移动

我正在努力找出我做错了什么

这是相关代码,
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
我不明白为什么这是一个问题。查看另一篇文章(),我确实确保我测试的两个用户在所有目录中都具有完全权限,并且我正在将一个文件移动到另一个目录中的另一个文件名。这是参考文章中的决议之一

我还有第二个问题与错误有关。如前所述,如果我试图使用URL路径语法调试此问题,那么哪个用户正试图在服务器上执行此任务

该用户是否与在Visual Studio中调试的工作站上的用户相同,或者移动或复制请求是否由默认internet用户处理

我这样问是因为在修复了损坏的路径问题后,我仍然无法访问路径。使用URL调试错误,但不是在应用程序直接在服务器上运行时。我不知道F,但在Windows应用程序或Windows服务器中,您需要使用应用程序可执行路径并删除bin\Debug,如图所示

 string startupPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) + "\\Templates");

 startupPath = startupPath.Replace("bin\\Debug\\", string.Empty);

 var newfileName2 = Guid.NewGuid() + ".xlsx";

 string destinationPath = Path.Combine(startupPath, newfileName2);

 File.Copy(sourcefile, destinationPath, true);

这是C代码。发布此代码以了解您的问题

首先,存在路径问题。正在使用文件名将部分路径(不带文件名)复制到完整路径中。一旦应用程序的Access数据库(程序使用的路径源)设置回使用标准Windows驱动器路径--
G:\dir1\dir2\file1.007
并且修复了无效路径,程序将恢复正常


如果
File.Move
(或Copy)会提供更可靠的错误,那就更好了。

请您准确解释一下
currentPath
destPath
的值是如何在程序中获得或声明的?我想知道它是否在某种程度上与双反斜杠无关(或者在
musys\u read\musys
中缺少双反斜杠)…@thomascorbieère我发现了这个问题。这是一个错误的路径。此程序正在Visual Studio 2012外使用URL路径执行,这是为了调试目的。生产应用程序使用驱动器号和路径,并得到相同的错误。所以,我对你的答案感到困惑。