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对象表示在磁盘或网络路径上指向文件的流.这个类提供了在文件中读写字 ...
随机推荐
- yum 软件管理器
yum软件管理器 yum是一个强大的软件包管理器,能够自动解决安装时rpm包之间的依赖关系. 一.使用yum管理软件包 1.使用命令 yum help 查看使用方法 [root@majinhai ~] ...
- 树莓派 - 驱动hello
树莓派上Linux驱动,从hello world 开始 ... hello.c #include <linux/init.h> #include <linux/module.h> ...
- 一个关于vue+mysql+express的全栈项目(二)------ 前端构建
一.使用vue-cli脚手架构建 <!-- 全局安装vue-cli --> npm install -g vue-cli <!-- 设置vue webpack模板 --> vu ...
- ACdream 1063 字典树
ACdream 1063 字典树 平衡树 神奇的cxlove有一颗平衡树,其树之神奇无法用语言来描述 OrzOrz. 这棵树支持3种操作: 1.加入一个数到树中,维护平衡树的合法性: 2.给一个数X, ...
- [bzoj2822][AHOI2012]树屋阶梯 (卡特兰数+分解质因数+高精度)
Description 暑假期间,小龙报名了一个模拟野外生存作战训练班来锻炼体魄,训练的第一个晚上,教官就给他们出了个难题.由于地上露营湿气重,必须选择在高处的树屋露营.小龙分配的树屋建立在一颗高度为 ...
- 九度oj 题目1473:二进制数(stack)
题目1473:二进制数 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:9371 解决:2631 题目描述: 大家都知道,数据在计算机里中存储是以二进制的形式存储的. 有一天,小明学了C语 ...
- ajax接收json数据到js解析
今天又学到了一点新知识,脑子记不住东西特把它记录下来! 页面ajax请求后台时一般都是返回字符串进行判断,要是返回list或者对象时该怎么办? 第一种:ajax接收到list并返回给前台 js代码: ...
- javaweb开发页面数字过长显示科学计数法的问题
1. 检查该字段是否为double类型,如果是,请改成BigDecimal 2.如果是导出excel里面为科学计数法,原页面正常,是因为excel设置的原因,请参考https://jingyan.ba ...
- Ubuntu 16.04安装Memcached(单机)
Ubuntu 16.04安装Memcached,不过不仅限与Ubuntu,可以用CentOS等去安装,只不过测试时使用的是Ubuntu机器.Windows下不建议使用,本机调试可以使用,线上环境除了W ...
- linux 的硬链接与软连接
linux 里有硬链接和软连接两种概念.要明白这些概念首先要明白文件在linux 上其实有3个组成部分. data 真正的数据存储区域 inode 一个用来唯一表示data的数据结构 filename ...