File.Copy从Unc路径到(同一服务器)Unc路径查询
在使用 C# 的 File.Copy 的场景中,数据流量是通过主机应用程序还是远程处理:
File.Copy(@"\\SERVER13\LOL\ROFL.txt", @"\\SERVER13\ROFL.txt")
干杯,谢谢!
Will data traffic go through the host application program or will be dealt remotely in scenarios where C#'s File.Copy is used:
File.Copy(@"\\SERVER13\LOL\ROFL.txt", @"\\SERVER13\ROFL.txt")
Cheers n thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它将通过本地应用程序。文件系统不知道应用程序将如何处理从共享读取的字节,也不知道写入共享的字节来自何处。
此外,应用程序不知道(在 DFS 的情况下)这两个共享是否位于同一台计算机上。
It will go through the local application. The file system does not know what the application is going to do with the bytes it reads from the share, or where the bytes that are written to the share come from.
In addition, the application does not know (in the case of DFS) if the two shares are on the same machine.
如果想让服务器来处理,就必须远程运行一个复制程序。
If you want to let the server handle it, you have to remotely run a copy program.
首先,目标文件的路径中有一个小错误。
其次,没有远程复制操作。存在远程移动操作(重命名,但目标位于其他目录中),例如
MoveFile
(请参阅本机 API http://msdn.microsoft.com/en-us/library/aa365239%28VS.85%29.aspx)。更新:您可能来自 unix,并且知道实用程序 rcp,但它适用于远程 shell 服务 (rshd),而不适用于直接文件系统功能。您还可以使用 SysInternals 中的 PsExec 实用程序(请参阅 http://technet.microsoft。 com/en-us/sysinternals/bb897553.aspx)来启动远程计算机上的某些程序,但这一切都不是编程的主题。
First of all you have a small bug in the path of the destination file.
Second, there are no remote copy operation. There exist a remote move operation (rename, but with a destination in other directory) like
MoveFile
(see native API http://msdn.microsoft.com/en-us/library/aa365239%28VS.85%29.aspx).UPDATED: Probably you came from unix and knows utility rcp, but it works with respect of remote shell service (rshd) and not with respect of direct file system features. You can also use PsExec utility from SysInternals (see http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) to start some program on the remote computer, but all this is not a subject of programming.