FileStream StreamWriter StreamReader BinaryReader
FileStream vs/differences StreamWriter?
http://stackoverflow.com/questions/4963667/filestream-vs-differences-streamwriter
What is different between FileStream and StreamWriter in dotnet?
A FileStream is a Stream. Like all Streams it only deals with byte[] data.
A StreamWriter is a TextWriter, a Stream-decorator. A TextWriter converts or encodes Text data like string or char to byte[] and then writes it to the linked Stream.
What context are you supposed to use it? What is their advantage and disadvantage?
You use a bare FileStream when you have byte[] data. You add a StreamWriter when you want to write text.
Is it possible to combine these two into one?
Yes. You always need a Stream to create a StreamWriter. System.IO.File.CreateText("path") will create them in combination and then you only have to Dispose() the outer writer.
StreamReader vs BinaryReader?
http://stackoverflow.com/questions/10353913/streamreader-vs-binaryreader
Both StreamReader and BinaryReader can be used to get data from binary file
Well, StreamReader can be used to get text data from a binary representation of text.
BinaryReader can be used to get arbitrary binary data. If some of that binary data happens to be a representation of text, that's fine - but it doesn't have to be.
Bottom line:
- If the entirety of your data is a straightforward binary encoding of text data, use
StreamReader. - If you've fundamentally got binary data which may happen to have some portions in text, use
BinaryReader
So for example, you wouldn't try to read a JPEG file with StreamReader.
FileStream StreamWriter StreamReader BinaryReader的更多相关文章
- File FileStream StreamWriter StreamReader文件读写操作方法
string path = "D:\\AccountChecking\\Test.txt"; string content = "abcdefg\r\nhigklmn\r ...
- C#对文件/目录的操作:Path、File、Directory、FileStream、StreamReader、StreamWriter等类的浅析
以下类的命名空间都是:System.I/0; 一.Path:主要对文件路径的操作! 常用方法: String path=@"C:\a\b\c\123.txt"; 1-1.Path. ...
- 文件流操作(FileStream,StreamReader,StreamWriter)
大文件拷贝: /// <summary> /// 大文件拷贝 /// </summary> /// <param name="sSource"> ...
- C#中FileStream和StreamWriter/StreamReader的区别
首先致谢!转自:http://blog.sina.com.cn/s/blog_67299aec0100snk4.html 本篇可能不是非常深入,但是胜在清晰明了 FileStream对象表示在 ...
- c#StreamWriter,StreamReader类(主要用于文本文件访问)
1.为什么要使用StreamReader或者StreamWriter 如果对文本文件需要读取一部分显示一部分则使用FileStream会有问题,因为可能FileStream会在读取的时候把一个汉字的字 ...
- 【基础巩固】文件流读写、大文件移动 FileStream StreamWriter File Path Directory/ ,m资料管理器(递归)
C#获取文件名 扩展名 string fullPath = @"d:\test\default.avi"; string filename = Path.GetFileName(f ...
- StreamWriter StreamReader
private void WriteLoginJsonData(object jsonData) { using (FileStream writerFileStream = new FileStre ...
- 利用FileStream实现多媒体文件复制
利用FileStream实现多媒体文件复制的主要思路在于利用两个FileStream对象,一个读取字节,另一个对象写入字节既可. 涉及知识点: 1.通常我们操作的File类,FileS ...
- FileStream和BinaryReader,BinaryWriter,StreamReader,StreamWriter的区别
FileStream对于在文件系统上读取和写入文件非常有用,FileStream缓存输入和输出,以获得更好的性能.FileStream对象表示在磁盘或网络路径上指向文件的流.这个类提供了在文件中读写字 ...
随机推荐
- Python学习笔记(1)——Python的概述(Python的环境、变量、数据类型、基本运算)
Table of Contents 1. Python概述 1.1. Python基础知识 1.2. 运行环境 1.3. Python的格式 1.4. Python的变量. 2. Python的数据类 ...
- c语言中的 strcpy和strncpy字符串函数使用介绍
1.strcpy函数 函数原型:char *strcpy(char *dst,char const *src) 必须保证dst字符的空间足以保存src字符,否则多余的字符仍然被复 ...
- 15Spring泛型依赖注入
Spring 4.x中可以为子类注入子类对应的泛型类型的成员变量的引用 BaseService<T>:有RoleService和UserService两的子类 BaseRepepositr ...
- Python之模块和包的创建与使用
一.模块的概念 在计算机的开发过程中,随着程序代码越写越多,在一个文件里代码就越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,放在不同的文件里面,这样,每个文件包含的代码就相对 ...
- stark组件之注册与路由系统(三)
在文章stark组件前戏中已经提到过,django的注册功能是通过AdminSite的单例进行组册的,所以在这里也可以进行单例模式. class AdminSite(object): def __in ...
- SQLAlchmy模块详解
之前写过一篇博客介绍过sqlalchemy的基本用法,本篇博客主要介绍除增删改查以外SQLAlchemy对数据库表的操作,主要内容有单表操作.一对多操作.多对多操作. 一.单表操作 单表操作的增删改查 ...
- CSUOJ 1542 线段树解决括号反向问题
题目大意: 根据初始给定的合法的小括号排序,每次进行一个操作,将第a位的括号反向,找到一个尽可能靠前的括号反向后是整个括号排列合法 数据量十分大,不断进行查询,要用线段树进行logn的复杂度的查询 首 ...
- SBT 模板不完全总结,后续待填
; ; ; ; ){ ; &&k<T[r].key)||(T[r].right==&&k>T[r].key)){ ); } ...
- navicat mysql 连接本地 忘记密码 查看密码 操作
https://jingyan.baidu.com/article/454316ab4e9e65f7a7c03ad1.html
- BZOJ 3754 Tree之最小方差树 MST
Description Wayne 在玩儿一个很有趣的游戏.在游戏中,Wayne 建造了N 个城市,现在他想在这些城市间修一些公路,当然并不是任意两个城市间都能修,为了道路系统的美观,一共只有M 对城 ...