For 1 specific file I get wrong data after char 813302
It doesnt seem related to the size of the file, larger files work fine.
I do have an example that reproduces this, but so far I have only been able to reproduce it with sensitive data.
After compressing/decompressing I get:
In the original it said:
So the two Field are swapped, also there is some strange tag RowAANdh in it that I cant explain, it looks like the RowGroup="88"
The code I use is below
The output I get is:
Loading file: ..\..\PowerBrowser.gpf
Length original: 5691434
Length after compress/decompress: 5657083
Index first difference: 813302
It doesnt seem related to the size of the file, larger files work fine.
I do have an example that reproduces this, but so far I have only been able to reproduce it with sensitive data.
After compressing/decompressing I get:
<
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"
/>
In the original it said:
<
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"
/>
So the two Field are swapped, also there is some strange tag RowAANdh in it that I cant explain, it looks like the RowGroup="88"
The code I use is below
The output I get is:
Loading file: ..\..\PowerBrowser.gpf
Length original: 5691434
Length after compress/decompress: 5657083
Index first difference: 813302
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");
}
}
}