FileStream vs/differences StreamWriter?
https://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.
最新文章
- Python标准模块--os
- Linux系统值得一看的学习方法及路线图
- 【百度百科】对焦Focus
- 【BZOJ】1109: [POI2007]堆积木Klo
- NuGet学习笔记
- C# 网络编程之网页简单下载实现
- css样式表中四种属性选择器
- Zepto.js入门介绍
- id 生成器介绍
- 资深实践篇 | 基于Kubernetes 1.61的Kubernetes Scheduler 调度详解
- Python Django连接(听明白了是连接不是创建!)Mysql已存在的数据库
- Mac之brew使用
- webRTC中音频相关的netEQ(二):数据结构
- [转]调试利器-SSH隧道
- RocketMQ之消息幂等
- ssm中的某些异常
- Window Screen对象
- 何时使用copy,strong,weak,assign关键字 定义属性
- 三、hdfs的JavaAPI操作
- js_layer弹窗的使用和总结
热门文章
- Lists and tuples
- 18.查询效率最高的unordered_map
- [学习笔记]AJAX学习
- 洛谷P2839 [国家集训队]middle 主席树_二分
- 20180929 北京大学 人工智能实践:Tensorflow笔记02
- caioj 1071 动态规划入门(二维一边推4:相似基因) (最长公共子序列拓展)
- Java基础学习总结(15)——java读取properties文件总结
- Qt 5.3 下OpenCV 2.4.11 开发(0)图像处理基本概念
- ORA-01003: no statement parsed
- HDU 5303 Delicious Apples(贪心 + 背包 2015多校啊)