本文整理汇总了C#中System.IO.Stream.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.WriteTo方法的具体用法?C# Stream.WriteTo怎么用?C# Stream.WriteTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了Stream.WriteTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compress
public byte[] Compress(Stream inputStream)
{
using (var outputStream = new MemoryStream())
using (var bzip2 = new BZip2OutputStream(outputStream))
{
inputStream.WriteTo(bzip2);
return outputStream.ToArray();
}
}
示例2: Compress
public byte[] Compress(Stream inputStream)
{
using (var outputStream = new MemoryStream())
using (var zlibStream = new ZlibStream(outputStream, CompressionMode.Compress))
{
inputStream.WriteTo(zlibStream);
return outputStream.ToArray();
}
}
示例3: Store
public override void Store(Stream stream, FileSystemObject fso)
{
CreateFolder(fso.FolderName);
using (var fs = new FileStream(fso.FullName, FileMode.Create, FileAccess.Write))
{
stream.WriteTo(fs);
}
}
示例4: Compress
public byte[] Compress(Stream inputStream)
{
byte[] result;
MemoryStream outputStream = null;
try
{
outputStream = new MemoryStream();
using (var deflateStream = new DeflateStream(outputStream, CompressionMode.Compress))
{
inputStream.WriteTo(deflateStream);
result = outputStream.ToArray();
}
}
finally
{
if (outputStream != null)
{
outputStream.Dispose();
}
}
return result;
}