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.

最新文章

  1. Python标准模块--os
  2. Linux系统值得一看的学习方法及路线图
  3. 【百度百科】对焦Focus
  4. 【BZOJ】1109: [POI2007]堆积木Klo
  5. NuGet学习笔记
  6. C# 网络编程之网页简单下载实现
  7. css样式表中四种属性选择器
  8. Zepto.js入门介绍
  9. id 生成器介绍
  10. 资深实践篇 | 基于Kubernetes 1.61的Kubernetes Scheduler 调度详解
  11. Python Django连接(听明白了是连接不是创建!)Mysql已存在的数据库
  12. Mac之brew使用
  13. webRTC中音频相关的netEQ(二):数据结构
  14. [转]调试利器-SSH隧道
  15. RocketMQ之消息幂等
  16. ssm中的某些异常
  17. Window Screen对象
  18. 何时使用copy,strong,weak,assign关键字 定义属性
  19. 三、hdfs的JavaAPI操作
  20. js_layer弹窗的使用和总结

热门文章

  1. Lists and tuples
  2. 18.查询效率最高的unordered_map
  3. [学习笔记]AJAX学习
  4. 洛谷P2839 [国家集训队]middle 主席树_二分
  5. 20180929 北京大学 人工智能实践:Tensorflow笔记02
  6. caioj 1071 动态规划入门(二维一边推4:相似基因) (最长公共子序列拓展)
  7. Java基础学习总结(15)——java读取properties文件总结
  8. Qt 5.3 下OpenCV 2.4.11 开发(0)图像处理基本概念
  9. ORA-01003: no statement parsed
  10. HDU 5303 Delicious Apples(贪心 + 背包 2015多校啊)