-1
string hexstr = http.Body.ToString();
if (hexstr.Contains("1f8b"))
{
    Stream str = http.Body.ToMemoryStream();
    str.Position = str.Seek(0x1f8b, SeekOrigin.Begin);
    using (var zipStream = new GZipStream(str, CompressionMode.Decompress))
    using (var resultStream = new MemoryStream())
    {
        zipStream.CopyTo(resultStream);
        return resultStream.ToArray();
    }
}

How can I trim a stream and make its beginning point as 1F8B.

FortyTwo
  • 2,414
  • 3
  • 22
  • 33

1 Answers1

2

Searching for the searchstring and cutting the string so that it starts with the searchstring - you can easily do it like this:

string hexstr = http.Body.ToString();
string search = "1f8b";
if (hexstr.Contains(search))
{
   int pos = hexstr.IndexOf(search);
   hexstr = hexstr.Substring(pos, hexstr.Length - pos);
   // do something additional with hexstr...
}
Adelphos
  • 83
  • 7