本文整理汇总了C#中System.IO.Compression.GZipStream.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.Compression.GZipStream.Flush方法的具体用法?C# System.IO.Compression.GZipStream.Flush怎么用?C# System.IO.Compression.GZipStream.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Compression.GZipStream
的用法示例。
在下文中一共展示了System.IO.Compression.GZipStream.Flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compress
/// <summary>
/// Compress with Stream
/// </summary>
public static void Compress(Stream input)
{
System.IO.Compression.GZipStream stream =
new System.IO.Compression.GZipStream(
input, System.IO.Compression.CompressionMode.Compress, true);
stream.Flush();
}
示例2: UnGZIP
public static string UnGZIP(ref byte[] input)
{
System.IO.MemoryStream oMemoryStream = null;
System.IO.Compression.GZipStream oGZipStream = null;
int iLength = 0;
byte[] byteArray = new byte[100001];
System.Text.StringBuilder oStringBuilder = new System.Text.StringBuilder();
oMemoryStream = new System.IO.MemoryStream(input);
oGZipStream = new System.IO.Compression.GZipStream(oMemoryStream, System.IO.Compression.CompressionMode.Decompress);
oMemoryStream.Flush();
oGZipStream.Flush();
do
{
iLength = oGZipStream.Read(byteArray, 0, byteArray.Length);
if (iLength < 1)
break; // TODO: might not be correct. Was : Exit Do
oStringBuilder.Append(System.Text.Encoding.UTF8.GetString(byteArray, 0, iLength));
} while (true);
oGZipStream.Close();
oMemoryStream.Close();
oGZipStream.Dispose();
oMemoryStream.Dispose();
return oStringBuilder.ToString();
}
示例3: Save
public void Save(string path)
{
if (!System.IO.Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
System.IO.FileStream fs = new System.IO.FileStream(GetFilePath(path, this.CategoryName), System.IO.FileMode.Create);
System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(fs, System.IO.Compression.CompressionMode.Compress);
ProtoBuf.Serializer.PrepareSerializer<CompositionCategory>();
ProtoBuf.Serializer.Serialize(gz, this);
gz.Flush();
gz.Close();
fs.Close();
}