为什么File.Exists()慢得多,当文件不存在?

编程入门 行业动态 更新时间:2024-10-28 12:25:04
本文介绍了为什么File.Exists()慢得多,当文件不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我看来,File.Exists()慢得多,当文件不存在,或使用不具有访问时,该文件确实存在比?这是没有道理给我。

Seems to me that File.Exists() is much slower when the file does not exist or the use doesn't have access than when the file does exist? This doesn't make sense to me.

推荐答案

通常,当你搜索了一堆东西的东西,你也不能肯定他们缺乏生存的,除非你搜索的所有可能的地方的也有可能是。当寻找的东西(在大多数种的集合)的最坏的情况是,当该项目不集合中存在

Generally when you search a bunch of stuff for something, you can't be sure about their lack of existence unless you have searched all possible places it could have been. When searching for something (in most kinds of collections) the worst case is when the item doesn't exist in the collection.

我没有基准 File.Exists 特别,但我高度怀疑,有一个在这些情况下,一个非常明显的区别,除非你正在做上千次。你是如何达到这个结论的?

I have not benchmarked File.Exists in particular but I highly doubt that there's a really noticeable difference in those cases unless you're doing it thousands of times. How did you reach to this conclusion?

更多推荐

为什么File.Exists()慢得多,当文件不存在?

本文发布于:2023-06-08 14:27:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583066.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:得多   不存在   文件   File   Exists

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!