Post: [C#] StreamExtensions Class
07-01-2011, 06:36 AM #1
Blackstorm
Veni. Vidi. Vici.
(adsbygoogle = window.adsbygoogle || []).push({}); Well, here's this class I use with IO Streams, etc. It is really useful, I used it for patches though. :p

Here's the class:

You must login or register to view this content.

Make sure you add the class manually (Project -> Add Class) or it won't work correctly. :p

Here's an example of how I used it:

    
for (var i = 0; i < 21; i++)
{
blockStart = ffReader.BaseStream.Position;
blockSize = ffReader.BaseStream.ReadInt16();
if (ffReader.BaseStream.Position.ToString("X") == "B4A0")
blockSize = 39599;
else if (ffReader.BaseStream.Position.ToString("X") == "14F51")
blockSize = 65443;
tempData = ffReader.ReadBytes((int)blockSize);
compData = new byte[tempData.Length + 2];
Buffer.BlockCopy(zlibHeader, 0, compData, 0, 2);
Buffer.BlockCopy(tempData, 0, compData, 2, tempData.Length);
decompData = ZlibStream.UncompressBuffer(compData);
zoneWriter.BaseStream.Write(decompData, 0, decompData.Length);
Array.Clear(tempData, 0, tempData.Length);
Array.Clear(compData, 0, compData.Length);
Array.Clear(decompData, 0, decompData.Length);
}
zoneWriter.Close();
ffReader.Close();


Enjoy, also, I take NO credit at all for that class, CraigChrist simply referred me to it, and I found it useful so I decided to post it. Smile

The following 2 users say thank you to Blackstorm for this useful post:

Woof, Shootprado
07-08-2011, 05:33 AM #2
kiwimoosical
Bounty hunter
For those of you wondering, it is SotG Caboose's work, just sayin
07-25-2011, 12:14 PM #3
Woof
...hmm
Thanks for sharing this with us Blackstorm! :y:
I just made the class file of it. Smile
08-03-2011, 02:11 AM #4
kiwimoosical
Bounty hunter
This is a good class btw. Caboose's work is good.

Copyright © 2025, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo