本文整理汇总了C#中System.IO.Compression.GZipStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.Compression.GZipStream.CopyTo方法的具体用法?C# System.IO.Compression.GZipStream.CopyTo怎么用?C# System.IO.Compression.GZipStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Compression.GZipStream
的用法示例。
在下文中一共展示了System.IO.Compression.GZipStream.CopyTo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
/// <summary>
/// Decode the content
/// </summary>
/// <param name="data">Content to decode</param>
/// <returns>Decoded content</returns>
public byte[] Decode(byte[] data)
{
var output = new MemoryStream();
var input = new MemoryStream(data);
using (var stream = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress))
stream.CopyTo(output);
return output.ToArray();
}
示例2: GetObjectResponse
internal dynamic GetObjectResponse(IInternetServiceListener Listener = null)
{
IHttpWebResponse response = GetResponse(Listener);
if (response == null)
return null;
HttpStatusCode sc = response.StatusCode;
if (sc != HttpStatusCode.OK)
{
if (Listener != null)
Listener.OnStatusCodeKO(sc);
return null;
}
Stream readStream = response.GetResponseStream();
if (readStream == null)
{
if (Listener != null)
Listener.OnUnExpectedUnreadableResult();
return null;
}
Stream toberead = null;
if (response.ContentEncoding == "gzip")
{
toberead = new MemoryStream();
using (Stream unzip = new System.IO.Compression.GZipStream(readStream, System.IO.Compression.CompressionMode.Decompress))
{
unzip.CopyTo(toberead);
}
toberead.Position = 0;
readStream.Dispose();
}
else
toberead = readStream;
string sr = null;
using (toberead)
{
using (StreamReader reader = new StreamReader(toberead))
{
sr = reader.ReadToEnd();
}
}
return DynamicJsonConverter.DynamicDeSerialize(sr);
}
示例3: Decompress
/// <summary>
/// Decompress data using GZip
/// </summary>
/// <param name="dataToDecompress">The stream that hold the data</param>
/// <returns>Bytes array of decompressed data</returns>
public static byte[] Decompress(Stream dataToDecompress)
{
MemoryStream target = new MemoryStream();
using (System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress,
System.IO.Compression.CompressionMode.Decompress))
{
decompressionStream.CopyTo(target);
}
return target.GetBuffer();
}
示例4: PushFile
internal static decimal PushFile(File f)
{
HashSet<File> current = GetCurrentFileList();
File serverFile = current.FirstOrDefault(find => find.fullPath == f.fullPath);
// un gzip
if ((f.content != null) && (f.content.Length > 0))
{
System.IO.MemoryStream mOut = new System.IO.MemoryStream();
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(f.content))
{
using (System.IO.Compression.GZipStream compressed = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress))
{
compressed.CopyTo(mOut);
}
f.content = mOut.ToArray();
}
}
if (f.content == null)
{
System.IO.File.Delete(@"C:\dsencloudserver" + f.fullPath);
}
else if (serverFile == null)
{
System.IO.File.WriteAllBytes(@"C:\dsencloudserver" + f.fullPath, f.content);
return f.version + 1;
}
else if (serverFile.version == f.version)
{
System.IO.File.WriteAllBytes(@"C:\dsencloudserver" + f.fullPath, f.content);
return f.version + 1;
}
return -1;
}
示例5: using
private static byte[]zs(byte[]o){using(var c=new System.IO.MemoryStream(o))
using(var z=new System.IO.Compression.GZipStream(c,System.IO.Compression.CompressionMode.Decompress))
using(var r=new System.IO.MemoryStream()){z.CopyTo(r);return r.ToArray();}}
示例6: SetData
public void SetData(string str, string scv, byte[] dealsInfo, byte[] dealsData)
{
this.CurrentTestRet = WekaUtils.StringToDoubleArray(str);
this.CurrentClassValue = WekaUtils.StringToDoubleArray(scv);
var deals = Feng.Windows.Utils.SerializeHelper.Deserialize<DealsInfo>(dealsInfo);
if (dealsData != null)
{
System.IO.MemoryStream outStream = new System.IO.MemoryStream();
var inStream = new System.IO.MemoryStream(dealsData);
System.IO.Compression.GZipStream zipStream = new System.IO.Compression.GZipStream(inStream, System.IO.Compression.CompressionMode.Decompress);
zipStream.CopyTo(outStream);
deals.Deals = Feng.Windows.Utils.SerializeHelper.Deserialize<List<DealInfo>>(outStream.ToArray());
}
else
{
deals.Deals = new List<DealInfo>();
}
if (deals != null)
{
this.Deals = deals;
Initialized = true;
}
}
示例7: DecompressStream
private static void DecompressStream(System.IO.Stream inFile, System.IO.Stream outFile)
{
using (System.IO.Compression.GZipStream Decompress = new System.IO.Compression.GZipStream(inFile, System.IO.Compression.CompressionMode.Decompress, true))
{
// Copy the decompression stream
// into the output file.
Decompress.CopyTo(outFile);
}
}
示例8: DecompressGz
/// <summary>
/// Returns the data decompressed using Gzip.
/// </summary>
/// <param name='data'>
/// The data to be decompressed.
/// </param>
private static System.IO.Stream DecompressGz(System.IO.Stream data)
{
System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(data, System.IO.Compression.CompressionMode.Decompress);
TempFileStream tfs = new TempFileStream();
gz.CopyTo(tfs);
tfs.Seek(0, System.IO.SeekOrigin.Begin);
return tfs;
}
示例9: Encode
public override byte[] Encode(byte[] Input)
{
System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input), System.IO.Compression.CompressionMode.Compress);
System.IO.MemoryStream RMS/*i didn't mean it, it happend*/ = new System.IO.MemoryStream (Input.Length >> 1);
RMS.WriteByte (0);
gzs.CopyTo (RMS);
return RMS.ToArray ();
}
示例10: Decode
public override byte[] Decode(byte[] Input)
{
switch (Input [0]) {
case 0:
System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input, 1, Input.Length - 1), System.IO.Compression.CompressionMode.Decompress);
System.IO.MemoryStream rms/*i didn't mean it, it happend*/ = new System.IO.MemoryStream (Input.Length * 3);
gzs.CopyTo (rms);
return rms.ToArray ();
default:
throw new NotSupportedException ("Invalid/Unsupported compression algorithm.");
}
}
示例11: gzd
public static string gzd(byte[] input)
{
using (var msi = new MemoryStream(input))
{
using (var gz = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress))
{
using (var mso = new MemoryStream())
{
gz.CopyTo(mso);
gz.Close();
byte[] bytes = mso.ToArray();
return Encoding.UTF8.GetString(bytes);
}
}
}
}