我创建了一个服务,将某个目录中的某些文件类型移动到另一个文件类型,这在本地运行良好,而且在我的网络上运行速度非常快。在不同的网络上,虽然它的工作速度非常慢(500mb文件需要6 1/2分钟),但通过资源管理器复制并粘贴到文件夹中的相同文件在大约30/40秒内完成。C#File.Move服务缓慢通过网络
发生文件移动的代码片段。
currentlyProcessing.Add(currentFile.FullName);
try
{
eventMsg("Attempting to move file","DEBUG");
File.Move(oldFilePath, newFilePath);
eventMsg("File Moved successfully","DEBUG");
}
catch (Exception ex)
{
eventMsg("Cannot Move File another resource is using it", "DEBUG");
eventMsg("Move File Exception : " + ex, "DEBUG");
}
finally
{
if(File.Exists(currentFile.FullName + ".RLK"))
{
try
{
File.Delete(currentFile.FullName + ".RLK");
}
catch (IOException e)
{
eventMsg("File Exception : " + e, "DEBUG");
}
}
currentlyProcessing.Remove(oldFilePath);
}
我担心的代码是罚款(因为它按预期工作的其他网络上),所以这个问题可能是网络,在某些形状或形式。有没有人有任何常见的技巧检查,服务作为本地系统(或网络服务)运行,并且似乎没有访问问题。还有什么其他因素会影响这个(网络/硬件除外)。
我想要的是它具有与我在资源管理器中见过的相似的传输速度。任何指针不胜感激。
我认为你需要使用ftp或任何这样的文件传输协议通过网络移动文件.. – dotNETbeginner