or
<Field Name="Datum wijziging" Type="2" Length="0" FieldName="MUT_DAT" Hint="Datum van de laatste wijziging" RowAANdh="0" FieldName="CREATOR_ID" Hint="Creator_id" /><Field Name="Datum aanmaak" Type="2" Length="0" FieldName="CREATEDATE" Hint="Createdate" /><Field Name="Datum aanmaak" Type="2" Length="0" FieldName="CREATEDATE" Hint="Createdate" /><Field Name="Datum wijziging" Type="2" Length="0" FieldName="MUT_DAT" Hint="Datum van de laatste wijziging" RowGroup="88" />using System.Windows;using System.Xml.Linq;using System;using System.IO;using Telerik.Windows.Zip;namespace TelerikTest{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = this; } public static byte[] Compress(string text) { using (MemoryStream memoryStream = new MemoryStream()) { using (ZipOutputStream zipOutputStream = new ZipOutputStream(memoryStream, ZipCompression.Deflated)) { using (StreamWriter streamWriter = new StreamWriter(zipOutputStream)) { streamWriter.Write(text); //streamWriter.Flush(); } byte[] bytes = memoryStream.ToArray(); return bytes; } } } public static string Decompress(byte[] data) { using (MemoryStream memoryStream = new MemoryStream(data)) { using (ZipInputStream zipInputStream = new ZipInputStream(memoryStream)) { using (StreamReader streamReader = new StreamReader(zipInputStream, new System.Text.UTF8Encoding())) { string text = streamReader.ReadToEnd(); return text; } } } } private void Button_Click(object sender, RoutedEventArgs e) { MainLog.AppendText(string.Format("Loading file: {0}\n", FileTextBox.Text)); XElement xml = XElement.Load(FileTextBox.Text); string text = xml.ToString(); MainLog.AppendText(string.Format("Length original: {0}\n", text.Length)); byte[] c = Compress(text); string text2 = Decompress(c); File.WriteAllText(@"..\..\OutputFromTelerikTest.gpf", text2); MainLog.AppendText(string.Format("Length after compress/decompress: {0}\n", text2.Length)); int indexFirstDifference = -1; for (int i = 0; i < Math.Min(text.Length, text2.Length); i++) { if (text[i] != text2[i]) { indexFirstDifference = i; break; } } MainLog.AppendText(string.Format("Index first difference: {0}\n", indexFirstDifference)); MainLog.AppendText("\n"); } }}
private string Compress(byte[] data) { MemoryStream memoryStream = new MemoryStream(); ZipCompression method = ZipCompression.Default; ZipOutputStream zipOutputStream = new ZipOutputStream(memoryStream, method); StreamWriter writer = new StreamWriter(zipOutputStream); writer.Write(data); writer.Flush(); return Convert.ToBase64String(memoryStream.ToArray()); }private byte[] UnCompress(string str) { MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(str)); ZipInputStream input = new ZipInputStream(memoryStream); StreamReader reader = new StreamReader(input); return memoryStream.ToArray(); }MemoryStream compressedStream;ZipPackage package;MemoryStream sourcestream = new MemoryStream();RadDocument document = this.CreateDocument(TileViewmodel);this.PrepareDocument(document);PdfFormatProvider provider = new PdfFormatProvider();provider.Export(document, sourcestream);compressedStream = new MemoryStream();package = ZipPackage.Create(compressedStream);package.AddStream(sourcestream, "WindowPeristedData");MemoryStream ms = new MemoryStream();byte[] zip = null;using ( ZipPackage zipfile = ZipPackage.Create(ms) ) { foreach ( var kvp in files ) { zipfile.AddStream(new MemoryStream(kvp.Value), kvp.Key, ZipCompression.Default, DateTime.Now); } zip = new byte[(int) ms.Length]; ms.Seek(0, SeekOrigin.Begin); ms.Read(zip, 0, (int) ms.Length); ms.Dispose();}return zip;Dim fname As String = System.IO.Path.Combine(System.Configuration.ConfigurationManager.AppSettings("GlobalUploadPath"), Filename) Dim fs As New FileStream(fname, FileMode.Open, FileAccess.Read) Try Using package = ZipPackage.Open(fs) Dim allEntries As List(Of ZipPackageEntry) = package.ZipPackageEntries For Each entry As ZipPackageEntry In allEntries Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(entry.FileNameInZip.ToLower) -->> wrong filenames in entry.FileNameInZip If tableList.Contains(filename) Then ' Reading the Data End If Next End UsingbusyIndicator.IsBusy = true; if (ListPic.Count > 0) { //Save zip File SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Zip File | *.zip"; bool? dialogResult = dialog.ShowDialog(); if (dialogResult == true) { using (ZipPackage zipPackage = ZipPackage.Create(dialog.OpenFile())) { foreach (PictureFile pic in ListPic) { Stream picStream = new MemoryStream(pic.PictureStream); zipPackage.AddStream(picStream, System.IO.Path.GetFileName(pic.PictureName),ZipCompression.Deflated,DateTime.Now); } } } busyIndicator.IsBusy = false; this.DialogResult = false; } else { busyIndicator.IsBusy = false; this.DialogResult = false; }