问题:
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);
- I need to save this to disk (I have the filename). 我需要将其保存到磁盘(我有文件名)。
- 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
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4262686