daily pastebin goal
18%
SHARE
TWEET

IsGZip (detecting gzip archive)

tolikpunkoff May 3rd, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public bool IsGZip(string filename)
  2.         {
  3.             byte[] buf = null;
  4.             try
  5.             {
  6.                 buf = File.ReadAllBytes(filename);
  7.             }
  8.             catch
  9.             {
  10.                 return false;
  11.             }
  12.  
  13.             if (buf.Length < 4) return false;
  14.  
  15.             if ((buf[0] == 0x1F) && (buf[1] == 0x8B) &&
  16.                 (buf[2] == 0x08) && (buf[3] == 0x00))
  17.                 return true;
  18.  
  19.             return false;
  20.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top