的System.IO.ReadAllxxx / WriteAllxxx方法的实施 [英] Performance of System.IO.ReadAllxxx / WriteAllxxx methods

查看:338
本文介绍了的System.IO.ReadAllxxx / WriteAllxxx方法的实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有System.IO.File.ReadAllxxx / WriteAllxxx方法VS的StreamReader / StremWriter课在网上提供任何性能比较。你认为什么是最好的方式(从性能的角度)来读取.NET 3.0 /写文本文件?

Is there any performance comparison of System.IO.File.ReadAllxxx / WriteAllxxx methods vs StreamReader / StremWriter classes available on web. What you think is the best way(from a performance perspective) to read/write text files in .net 3.0?

当我检查 MSDN系统的页面。 IO.File类 ,在C MS样品$ C $正在使用的StreamReader / StreamWriter的文件操作。有没有什么特别的原因,以避免File.ReadAllxxx / WriteAllxxx方法,即使他们看起来更容易理解?

When I checked the MSDN page of System.IO.File class, in the sample code MS is using StreamReader / StreamWriter for file operations. Is there any specific reason for avoiding File.ReadAllxxx / WriteAllxxx methods, even though they look much easier to understand?

推荐答案

您可能不希望使用File.ReadAllxxx / WriteAllxxx如果您有任何打算支持加载/保存的真正的大文件。

You probably don't want to use File.ReadAllxxx / WriteAllxxx if you have any intention to support loading / saving of really large files.

在换句话说,对于一个编辑器,你打算在编辑时,仍然可以使用技嘉大小的文件,你需要一些设计的StreamReader / StreamWriter的,追求,所以你加载的文件只有一部分是可见的。

In other words, for an editor which you intend to remain usable when editing gigabyte size files, you want some design with StreamReader/StreamWriter and seeking, so you load only the part of the file that is visible.

有关没有这些(罕见)要求什么,我会说,采取简单的方法,并使用File.ReadAllxxx / WriteAllxxx。他们只是使用相同的StreamReader /写入器模式在内部,你会code用手反正AKU所示。

For anything without these (rare) requirements, I'd say take the easy route and use File.ReadAllxxx / WriteAllxxx. They just use the same StreamReader/Writer pattern internally as you'd code by hand anyway, as aku shows.

这篇关于的System.IO.ReadAllxxx / WriteAllxxx方法的实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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