I zip string to byte array and unzip byte array to string in my .NET application.
Is it possible to check if byte array contains zipped string?
I.e. I want to avoid double zipping of already zipped string or trying to unzip plain text.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I could be wrong, but if I remember correctly the first two bytes of a zip file/stream have a signature. They should always be
PK.You could easily check the first two bytes of your byte array and see if they contains the ASCII values 80 (P) and 75 (K)
So supposing your byte array is called
data