static string LoadLevelDB() { var bitName = "x32"; long dllLength = 410624; if (Environment.Is64BitProcess) { bitName = "x64"; dllLength = 491520; } var folder = Path.Combine(GA.TempFolder, DLL_NAME_SIMPLE, bitName); GA.IO.CreateDirectory(folder); var dllFile = new FileInfo(Path.Combine(folder, DLL_NAME)); if (!dllFile.Exists || dllFile.Length != dllLength) { using (var stream = typeof(LDB).Assembly.GetManifestResourceStream("Aoite.LevelDB.Interop." + DLL_NAME_SIMPLE + bitName + ".gz")) { using (var gzipStream = new System.IO.Compression.GZipStream(stream, System.IO.Compression.CompressionMode.Decompress)) { using (var fileStream = dllFile.Create()) { gzipStream.CopyTo(fileStream); } } } } return(dllFile.FullName); }
public SKPicture Load(string path) { Reset(); var extension = System.IO.Path.GetExtension(path); switch (extension.ToLower()) { default: case ".svg": { var svgDocument = SvgDocument.Open <SvgDocument>(path, null); if (svgDocument != null) { svgDocument.FlushStyles(true); Picture = Load(svgDocument); Document = svgDocument; return(Picture); } return(null); } case ".svgz": { using (var fileStream = System.IO.File.OpenRead(path)) using (var gzipStream = new System.IO.Compression.GZipStream(fileStream, System.IO.Compression.CompressionMode.Decompress)) using (var memoryStream = new System.IO.MemoryStream()) { gzipStream.CopyTo(memoryStream); memoryStream.Position = 0; return(Load(memoryStream)); } } } }
/// <summary> /// Uncompress a string to a UTF8-8 string /// </summary> /// <param name="bytes"></param> /// <returns></returns> public static string Uncompress(this byte[] bytes) { using (var mso = new MemoryStream()) { MemoryStream msi = null; try { msi = new MemoryStream(bytes); using (var gs = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress, true)) { msi = null; gs.CopyTo(mso); } } finally { if (msi != null) { msi.Dispose(); } } return(Encoding.UTF8.GetString(mso.ToArray())); } }
internal static System.IO.FileInfo DecompressGZip(System.IO.FileInfo CompressedFile) { // Get the stream of the source file. using (System.IO.FileStream inFile = CompressedFile.OpenRead()) { // Get original file extension, for example // "doc" from report.doc.gz. string curFile = CompressedFile.FullName; string origName = curFile.Remove(curFile.Length - CompressedFile.Extension.Length); //Create the decompressed file. using (System.IO.FileStream outFile = System.IO.File.Create(origName)) { using (System.IO.Compression.GZipStream Decompress = new System.IO.Compression.GZipStream(inFile, System.IO.Compression.CompressionMode.Decompress)) { // Copy the decompression stream // into the output file. Decompress.CopyTo(outFile); } } return(new System.IO.FileInfo(origName)); } }
public static Data GzJsonDeSerialize(string fileName, Action <Exception> toLog = null) { if (System.IO.File.Exists(fileName) == false) { return(null); } Data result = null; try { using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)) using (System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(fs, System.IO.Compression.CompressionMode.Decompress, false)) using (System.IO.MemoryStream mso = new System.IO.MemoryStream()) { gz.CopyTo(mso); DataSize = mso.Length; mso.Position = 0; var serializer = new DataContractJsonSerializer(typeof(Data)); result = (Data)serializer.ReadObject(mso); } } catch (Exception ex) { if (toLog != null) { toLog(ex); } else { throw ex; } return(null); } return(result); }
/// <summary> /// Decompresses a file /// </summary> /// <param name="fileToDecompress"></param> /// <param name="outputPath"></param> public FileInfo Decompress(FileInfo fileToDecompress, FileInfo outputfile) { try { using (var originalFileStream = fileToDecompress.OpenRead()) { if ((System.IO.File.GetAttributes(fileToDecompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden) { if (string.IsNullOrEmpty(outputfile.FullName) || outputfile.Exists) { throw new Exception("File already exists."); } using (var decompressedFileStream = outputfile?.Create()) { using (var decompressionStream = new System.IO.Compression.GZipStream(originalFileStream, System.IO.Compression.CompressionMode.Decompress)) { decompressionStream.CopyTo(decompressedFileStream); } return(outputfile); } } throw new Exception("The file cannot be decompressed."); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
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; } }
private IEnumerable <VersionDescription> ParseResponse(WebHeaderCollection header, byte[] body) { switch (header.Get("Content-Encoding")) { case "gzip": using (var dst = new System.IO.MemoryStream()) using (var s = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(body), System.IO.Compression.CompressionMode.Decompress)) { s.CopyTo(dst); dst.Flush(); body = dst.ToArray(); } break; case "deflate": using (var dst = new System.IO.MemoryStream()) using (var s = new System.IO.Compression.DeflateStream(new System.IO.MemoryStream(body), System.IO.Compression.CompressionMode.Decompress)) { s.CopyTo(dst); dst.Flush(); body = dst.ToArray(); } break; default: break; } return(ParseAppCast(System.Text.Encoding.UTF8.GetString(body))); }
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()); }
private void UncompressedFile(string compressedFile, string uncompressedFile) { using (System.IO.Compression.GZipStream compressed = new System.IO.Compression.GZipStream(new FileStream(compressedFile, FileMode.Open, FileAccess.Read), System.IO.Compression.CompressionMode.Decompress)) using (FileStream uncompressed = new FileStream(uncompressedFile, FileMode.Create, FileAccess.Write)) { compressed.CopyTo(uncompressed); } }
/// <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(); }
public override void OnLoad() { if (!Directory.Exists(PluginDataDirectory)) { Directory.CreateDirectory(PluginDataDirectory); } if (!Directory.Exists(PluginDataDirectory + "\\Rift Teams")) { Directory.CreateDirectory(PluginDataDirectory + "\\Rift Teams"); } if (!Directory.Exists(PluginDataDirectory + "\\Rift Teams\\Archive")) { Directory.CreateDirectory(PluginDataDirectory + "\\Rift Teams\\Archive"); } if (File.Exists(PluginDataDirectory + "\\allMons.gz")) { using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(PluginDataDirectory + "\\allMons.gz"))) { using (System.IO.Compression.GZipStream gz = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress)) { using (MemoryStream os = new MemoryStream()) { gz.CopyTo(os); var ostr = Encoding.ASCII.GetString(os.ToArray()); allMons = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <ulong, KeyValuePair <RiftDeck, Monster> > > >(ostr); } } } foreach (var m in allMons.SelectMany(q => q.Value.Select(r => r.Value.Value))) { var tid = long.Parse(m.MonsterTypeId.ToString().Substring(0, m.MonsterTypeId.ToString().Length - 2) + "1" + m.MonsterTypeId.ToString().Last()); m.Name = MonsterName(tid); foreach (var r in m.Runes) { r.PrebuildAttributes(); m.ApplyRune(r); r.AssignedName = m.Name; r.Assigned = m; } } } if (File.Exists(PluginDataDirectory + "\\matchCount.json")) { matchCount = JsonConvert.DeserializeObject <Dictionary <RiftDungeon, Dictionary <string, Dictionary <string, int> > > >(File.ReadAllText(PluginDataDirectory + "\\matchCount.json")); } var files = Directory.GetFiles(PluginDataDirectory + "\\Rift Teams", "*.json"); foreach (var f in files) { ProcessDeck(File.ReadAllText(f)); File.Move(f, PluginDataDirectory + "\\Rift Teams\\Archive\\" + new FileInfo(f).Name); } loading = false; SaveStuff(); }
/// <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()); }
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); } }
internal void Open(long taskId) { this.Name = "t" + taskId + ".idx"; this.FullName = Path.Combine(Utilities.ConfigManager.GetValue("Backups.IndexFolder"), this.Name); if (!File.Exists(FullName)) { throw new Exception("This index doesn't exists or doesn't have a local copy"); } indexDbConn = new SqliteConnection(); //indexDbConn.ConnectionString = "Version=3;Synchronous=off;Compress=True;data source=file:"+this.FullName; indexDbConn.ConnectionString = "Version=3,Synchronous=off,data source=file:" + this.FullName + ""; indexDbConn.Open(); dataFormatter = new BinaryFormatter(); dataMs = new MemoryStream(); //get Header string headerQ = "SELECT data FROM header"; System.Data.IDbCommand headerC = indexDbConn.CreateCommand(); headerC.CommandText = headerQ; System.Data.IDataReader hReader = headerC.ExecuteReader(); hReader.Read(); dataMs = new MemoryStream(); long dataSize = hReader.GetBytes(0, 0, null, 0, 0); int offset = 0, bytesRead = 0; byte[] buffer = new byte[dataSize]; //Console.WriteLine ("open() read="+hReader.GetBytes(0, 0, buffer, offset, BUFFER_SIZE)); /*while((bytesRead = (int)hReader.GetBytes(0, offset, buffer, 0, 100)) > 0) { * Console.WriteLine("open() read header : read="+bytesRead+", offset="+offset); * dataMs.Write(buffer, 0, bytesRead); * offset += bytesRead; * * }*/ int curPos = 0; while (bytesRead < dataSize) { bytesRead += (int)hReader.GetBytes(0, curPos, buffer, curPos, (int)dataSize); curPos += bytesRead; } dataMs.Write(buffer, 0, bytesRead); dataMs.Flush(); //MemoryStream gzMs = new MemoryStream(); dataMs.Position = 0; using (MemoryStream uncompressedStream = new MemoryStream()){ using (gz = new System.IO.Compression.GZipStream(dataMs, System.IO.Compression.CompressionMode.Decompress, true)){ gz.CopyTo(uncompressedStream); } uncompressedStream.Position = 0; this.Header = (IndexHeader)dataFormatter.Deserialize(uncompressedStream); } dataMs.SetLength(0); }
static public byte[] DecompressGzip(byte[] compressed) { using (var decompressStream = new System.IO.Compression.GZipStream( new System.IO.MemoryStream(compressed), System.IO.Compression.CompressionMode.Decompress)) { var decompressedStream = new System.IO.MemoryStream(); decompressStream.CopyTo(decompressedStream); return(decompressedStream.ToArray()); } }
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); }
public static byte[] DecompressGzip(byte[] gzip_data) { using (var stream = new System.IO.Compression.GZipStream(new MemoryStream(gzip_data), System.IO.Compression.CompressionMode.Decompress)) { using (MemoryStream memory = new MemoryStream()) { stream.CopyTo(memory); return(memory.ToArray()); } } }
/// <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) { using (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.ToArray()); } }
/// <summary> /// Unzips the specified zipped bytes using an in-memory GZipStream. /// </summary> /// <param name="zippedBytes">The zipped bytes to unzip.</param> /// <param name="encoding">The Encoding to use to parse the bytes. Defaults to ASCII</param> /// <returns></returns> public static string Unzip(this byte[] zippedBytes, Encoding encoding = null) { using (var zipped = new MemoryStream(zippedBytes)) using (var unzipper = new System.IO.Compression.GZipStream(zipped, System.IO.Compression.CompressionMode.Decompress)) using (var unzippedBytes = new MemoryStream()) { unzipper.CopyTo(unzippedBytes); encoding = encoding ?? Encoding.ASCII; return(encoding.GetString(unzippedBytes.ToArray())); } }
public static byte[] Explode(this byte[] compressedBytes) { using (MemoryStream input = new MemoryStream(compressedBytes)) using (MemoryStream output = new MemoryStream()) { using (System.IO.Compression.GZipStream zip = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress)) { zip.CopyTo(output); } return(output.ToArray()); } }
private void DecompressToFile(string source, string dest) { using (System.IO.Compression.GZipStream stream = new System.IO.Compression.GZipStream(new System.IO.FileStream(source, System.IO.FileMode.Open), System.IO.Compression.CompressionMode.Decompress)) using (System.IO.FileStream outstream = new System.IO.FileStream(dest, System.IO.FileMode.Create)) { stream.CopyTo(outstream); outstream.Flush(); outstream.Close(); stream.Close(); } }
public static void UncompressFile(string fileName, byte[] content) { //byte[] buffer = new byte[4096]; //int n; using (var fs = File.Create(fileName)) using (var input = new System.IO.Compression.GZipStream(new MemoryStream(content), System.IO.Compression.CompressionMode.Decompress, false)) { //while ((n = input.Read(buffer, 0, buffer.Length)) > 0) // fs.Write(buffer, 0, n); input.CopyTo(fs); } }
/// <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(); }
public static string Uncompress(this byte[] bytes) { using (var msi = new MemoryStream(bytes)) using (var mso = new MemoryStream()) { using (var gs = new System.IO.Compression.GZipStream(msi, System.IO.Compression.CompressionMode.Decompress)) { gs.CopyTo(mso); } return(Encoding.UTF8.GetString(mso.ToArray())); } }
public string Decompress(string key) { var KeyByteArray = Convert.FromBase64String(key); var OutStream = new MemoryStream(); using (var Gzip = new System.IO.Compression.GZipStream(new MemoryStream(KeyByteArray), System.IO.Compression.CompressionMode.Decompress)) { Gzip.CopyTo(OutStream); Gzip.Close(); } return(Encoding.UTF8.GetString(OutStream.ToArray())); }
//zip解压缩字节 //1.创建被压缩的数据流 //2.创建zipStream对象,并传入解压的文件流 //3.创建目标流 //4.zipStream拷贝到目标流 //5.返回目标流输出字节 public static byte[] Decompress(byte[] bytes) { using (var compressStream = new MemoryStream(bytes)) { using (var zipStream = new System.IO.Compression.GZipStream(compressStream, System.IO.Compression.CompressionMode.Decompress)) { using (var resultStream = new MemoryStream()) { zipStream.CopyTo(resultStream); return(resultStream.ToArray()); } } } }
public Bell() { var gz = new System.IO.Compression.GZipStream( new MemoryStream(Convert.FromBase64String(Dataz), false), System.IO.Compression.CompressionMode.Decompress); var ms = new MemoryStream(); gz.CopyTo(ms); _data = ms.ToArray(); for (int i = 0; i < 3800; i++) // compensate for sample start point { Next(); } }
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."); } }
public void Decompress() { if (!isCompressed) { return; } System.IO.Compression.GZipStream compressedStream = new System.IO.Compression.GZipStream(image, System.IO.Compression.CompressionMode.Decompress); compressedStream.CopyTo(image); return; }
private static string _gzipDecompress(byte[] gZipBuffer) { //Prepare for decompress using (System.IO.MemoryStream output = new System.IO.MemoryStream()) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(gZipBuffer)) using (System.IO.Compression.GZipStream sr = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress)) { sr.CopyTo(output); } string str = Encoding.UTF8.GetString(output.GetBuffer(), 0, (int)output.Length); return(str); } }
public void UpdatePlayList(string NamePlayList, string PathFilePlayList, string PathFileUpdateTime, string LastModified) { System.IO.File.WriteAllText(PathFileUpdateTime, LastModified); System.Net.WebClient WC = new System.Net.WebClient(); WC.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"); WC.Encoding = System.Text.Encoding.UTF8; WC.Headers.Add("Accept-Encoding", "gzip, deflate"); byte[] Dat = WC.DownloadData("http://super-pomoyka.us.to/trash/ttv-list/ttv." + NamePlayList + ".iproxy.m3u?ip=" + IPAdress + ":" + PortAce); System.IO.FileStream decompressedFileStream = System.IO.File.Create(PathFilePlayList); System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(new System.IO.MemoryStream(Dat), System.IO.Compression.CompressionMode.Decompress); decompressionStream.CopyTo(decompressedFileStream); decompressedFileStream.Close(); decompressionStream.Close(); }
public async Task <X509Certificate2> GetCertificateAsync(string name, string password) { string base64String = await secretsStore.GetSecret(name); byte[] gzBytes = System.Convert.FromBase64String(base64String); using (var compressedStream = new MemoryStream(gzBytes)) using (var uncompressedStream = new MemoryStream()) using (var gz = new System.IO.Compression.GZipStream(compressedStream, System.IO.Compression.CompressionMode.Decompress)) { gz.CopyTo(uncompressedStream); // Unprotect certificate var certificate = new X509Certificate2(uncompressedStream.ToArray(), password); return(certificate); } }
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; }
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();}}
public override byte[] Encode(byte[] Input, byte[] Attributes) { if (Attributes == null) throw new ArgumentNullException ("Attributes"); if (Attributes.Length != 1) throw new ArgumentException ("Invalid Attributes supplied.", "Attributes"); System.IO.MemoryStream rms/*i didn't mean it*/ = new System.IO.MemoryStream (Input.Length >> 1); rms.WriteByte (Attributes [0]); switch (Attributes [0]) { case 0: System.IO.Compression.GZipStream gzs = new System.IO.Compression.GZipStream (new System.IO.MemoryStream (Input), System.IO.Compression.CompressionMode.Compress); gzs.CopyTo (rms); return rms.ToArray (); default: throw new Exception ("Unknown algorithm requested."); } }
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); } } } }
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."); } }
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; } }
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 (); }
/// <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; }