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对象表示在磁盘或网络路径上指向文件的流.这个类提供了在文件中读写字 ...
随机推荐
- 【讲●解】火车进出栈类问题 & 卡特兰数应用
火车进出栈类问题详讲 & 卡特兰数应用 引题:火车进出栈问题 [题目大意] 给定 \(1\)~\(N\) 这\(N\)个整数和一个大小无限的栈,每个数都要进栈并出栈一次.如果进栈的顺序为 \( ...
- RNN与情感分类问题实战-加载IMDB数据集
目录 Sentiment Analysis Two approaches Single layer Multi-layers Sentiment Analysis Two approaches Sim ...
- 九度oj 题目1052:找x
题目1052:找x 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9901 解决:5098 题目描述: 输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标 ...
- LaTex/Overleaf使用笔记
1. 添加网页引用 @misc{ r1, author = "Wikipedia", title = "Binary decision diagram --- { ...
- 变量&字符串
变量 变量定义规范: # 声明变量: name = "Neo Zheng" # name为变量名(标识符),"Neo Zheng"是变量值. 变量定义规则: 1 ...
- IDEA新手下载及和eclipse,myeclipse的区别
一:下载安装包,我们可以去官网下载.下载地址:http://www.jetbrains.com/idea/download/#secation=windows 二:IDEA的安装: 1.下载安装包后双 ...
- 洛谷 P4057 [Code+#1]晨跑
P4057 [Code+#1]晨跑 题目描述 “无体育,不清华”.“每天锻炼一小时,健康工作五十年,幸福生活一辈子” 在清华,体育运动绝对是同学们生活中不可或缺的一部分.为了响应学校的号召,模范好学生 ...
- Ubuntu 16.04设置Redis为开机自动启动服务
继上一篇文章http://www.cnblogs.com/EasonJim/p/7599941.html安装好Redis后,假设文件已经安装到/usr/local/redis目录下.假设我安装的版本为 ...
- mysql-performance-schema
http://www.fromdual.com/mysql-performance-schema-hints http://www.cnblogs.com/cchust/
- MongoDB小结07 - update【$addToSet & $each】
用$addToSet更新可以避免重复,将它与$each组合起来,可以一次性添加多条(就算后添加的值已存在也没有关系) db.user.update({"name":"co ...