【发布时间】:2017-02-03 16:20:28
【问题描述】:
我正在向System.IO.StreamWriter 写信。
底层流(在new StreamWriter(underlyingStream) 中指定)写入远程文件。 (我不认为它的类型是相关的,但为了完整起见,我会提到它是微软的 azure CloudBlobStream underlyingStream)。
现在,我想通过编写一个具有相同内容的附加压缩文件来扩展它,但在StreamWriter 和第二个CloudBlobStream 之间使用GZipOutputStream compressedUnderlyingStream。
我正在寻找一种方法来将两个CloudBlobStreams 指定为StreamWriter 的基础流。但我找不到办法。是否存在可以组合两个底层流的流类型?或者我该如何解决这个问题?请注意,我希望所有内容都保留为流,以最大限度地减少内存中的数据量。
//disregard lack of using statements for this example's sake
CloudBlobStream blobStream = blob.OpenWrite();
CloudBlobStream compressedBlobStream = compressedBlob.OpenWrite();
GZipOutputStream compressorStream = new GZipOutputStream(compressedBlobStream);
//I make the streamwriter here for the regular blob,
///but how could I make the same streamwriter also write to the compressedBlob at the same time?
TextWriter streamWriter = new StreamWriter(blobStream, Encoding.UTF8);
【问题讨论】:
-
目前没有
Stream这样的标准实现,需要自己制作。
标签: c# azure stream compression gzipstream