byte[] Compress() { AdvancedString Info = ""; foreach (PackEntry entry in Entries) { Info += Convert.ToString(entry.GetArchivePath()) + ";" + (entry.Data.Length) + "|"; } if (Info.EndsWith("|")) { Info = Info.Substring(0, Info.Length - 1); } Byte[] InfoBytes = System.Text.Encoding.Default.GetBytes(Info); int InfoBytesSize = InfoBytes.Length; Byte[] ByteInfoBytesSize = System.Text.Encoding.Default.GetBytes(InfoBytesSize.ToString()); //Fix Array Size to 4 if (ByteInfoBytesSize.Length < 4) { int d = 4 - ByteInfoBytesSize.Length; Byte[] temp = ByteInfoBytesSize; ByteInfoBytesSize = new Byte[4]; for (int i = 3; i >= 0; i += -1) { if (i - d >= 0) { ByteInfoBytesSize[i] = temp[i - d]; } else { ByteInfoBytesSize[i] = 0; } } } MemoryStream ms = new MemoryStream(); //Write InfoByteSize as Bytes[] ms.Write(ByteInfoBytesSize, 0, 4); //Write Info as Bytes[] ms.Write(InfoBytes, 0, InfoBytes.Length); //Write Files as Bytes[] foreach (PackEntry e in Entries) { ms.Write(e.Data, 0, e.Data.Length); } ms.Close(); byte[] buf = new byte[1024]; List <byte> data = new List <byte>(); while (ms.Read(buf, 0, 1024) > 0) { data.AddRange(buf); } return(data.ToArray()); }