File.Delete和Directory.Delete网络性能 [英] File.Delete and Directory.Delete network performance

查看:209
本文介绍了File.Delete和Directory.Delete网络性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道 File.Delete Directory.Delete 执行吗?



我的意思是:如果假设我通过网络删除一些文件/文件夹并且网络相当慢,会发生什么?

它会在本地完成吗?将文件移动到该网络位置会消耗更多的带宽吗?

解决方案

它不会像本地一样快。它会很慢,延迟取决于您的网络条件。



您不发送您的删除命令远程到知道如何删除一个文件夹作为原子操作的聪明的一端。您的代码实际上运行在网络位置愚蠢,并删除逐个文件。

至于你的最后一个问题,删除几乎总是比 Move 更快。在跨磁盘(当然也包括网络位置)移动文件时,它实际上是一个复制操作(在末尾有一个删除)。


Does anybody know how File.Delete and Directory.Delete execute?

I mean: what happens if assuming I were to delete some files/folders over the network and the network is considerably slow?

Would it complete as fast as it would be locally? Would it consume more bandwidth than say move files to that network location?

解决方案

It won't be as fast a it would be locally. It would be slow, with a latency that depends on your network conditions.

You don't send your Delete command "remotely" to a "smart end" which knows how to, say, delete a folder as an atomic operation. Your code actually runs against the network location which is "dumb" and deletes file-by-file.

As for your last question, Delete is almost always faster than Move. When you move files across disks (and of course across network locations), it's actually a copy operation (with a 'delete' at the end of it).

这篇关于File.Delete和Directory.Delete网络性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆