User (Old forums)MemberMarch 4, 2013 at 9:16 amPost count: 23064
Why compress results from xceed zip are diferent in c# and visula basic 6?
The byte array are diferent. Why?
public string compactaXceedStr(ref string dados, string senha = “”)
string strRet = “”;
xcdCompressionError oXceedretorno = new xcdCompressionError();
XceedCompression oXceed = new XceedCompression();
oDadoOriginal = (object)dados;
oXceed.EncryptionPassword = senha;
oXceedretorno = oXceed.Compress(ref oDadoOriginal, out oDadoCompactado, true);
if (oXceedretorno == xcdCompressionError.xceSuccess)
bytRet = (byte)oDadoCompactado;
//strRet = Convert.ToBase64String(bytRet);
strRet = System.Text.ASCIIEncoding.Default.GetString(bytRet);
strRet = oXceed.GetErrorDescription(Convert.ToInt16(oXceedretorno));
Public Function XCeedCompStr(ByRef varCadeia As Variant, Optional strSenha As String = “”) As String
Dim xcdZip As New XceedCompression, varZip As Variant, lngRetCode As xcdCompressionError
Dim strRet As String
If strSenha <> “” Then xcdZip.EncryptionPassword = strSenha
lngRetCode = xcdZip.Compress(StrConv(varCadeia, vbFromUnicode), varZip, True)
If lngRetCode = xceSuccess Then
strRet = StrConv(varZip, vbUnicode)
XCeedCompStr = strRet
Err.Raise lngRetCode, Err.Source & “@SPAUtil.Util.XceedCompStr”, xcdZip.GetErrorDescription(lngRetCode), Err.HelpFile, Err.HelpContext
Imported from legacy forums. Posted by Fabio (had 809 views)Diane [Xceed]ModeratorMarch 5, 2013 at 1:13 pmPost count: 1353
If encryption is used, the resulting compressed data will be different each time it is run because encryption always randomizes the data.
If encryption is not used and the compressed data is different, then the developer suspects that your source data is not actually the same between C# and VB6.
The Compress() and Uncompress() methods are meant to manipulate byte arrays. Not strings.
From your C# code, you take a System.String object and give it to Compress() as is. Is that your intention? Or would it be better to convert the string to a byte array first?
In VB6, you take a Variant and use StrConv().
If you want compression to have the same results, you should make sure your input data is exactly the same in both environments. C# and VB6 might not represent strings the same way. And in the Unicode world, there are various Unicode formats. C# strings store Unicode strings as Unicode 16. VB6 might not do the same thing, etc.
Imported from legacy forums. Posted by Diane [Xceed] (had 995 views)
- You must be logged in to reply to this topic.