如何将流保存到C#文件中?

Deadly 提交于 2020-05-03 15:13:24

问题:

I have a StreamReader object that I initialized with a stream, now I want to save this stream to disk (the stream may be a .gif or .jpg or .pdf ). 我有一个用流初始化的StreamReader对象,现在我想将此流保存到磁盘(该流可以是.gif.jpg.pdf )。

Existing Code: 现有代码:

StreamReader sr = new StreamReader(myOtherObject.InputStream);
  1. I need to save this to disk (I have the filename). 我需要将其保存到磁盘(我有文件名)。
  2. In the future I may want to store this to SQL Server. 将来我可能要将其存储到SQL Server。

I have the encoding type also, which I will need if I store it to SQL Server, correct? 我也有编码类型,如果将其存储到SQL Server,我会需要该编码类型,对吗?


解决方案:

参考一: https://stackoom.com/question/1j4a/如何将流保存到C-文件中
参考二: https://oldbug.net/q/1j4a/How-do-I-save-a-stream-to-a-file-in-C
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!