tags:

views:

70

answers:

3

Can someone provide an example or primer on working with files on a granular level with C#. Let's assume that I want to build a new program to compress and zip files. Can I write a program like this, with C#, that gets down to the bits & bytes level?

+1  A: 

I do not know of a good tutorial but BinaryReader is a good place to start for reading on the "bits & bytes" level

Scott Chamberlain
+5  A: 

You can surely read files byte by byte by using FileStream-class and the StreamReader-class. BinaryReader is even more granular. Having the bytes you will have the possibilty to work on bit-base with the bit-operators (|, &, <<, >>).

Examples can be found at the posted links.

P.S: You could use SharpZipLib or the Compression classes of .Net to compress files.

Simon
A: 

You can download the free #ziplib library including C# source code here:

http://www.icsharpcode.net/opensource/sharpziplib/

That should show you how to zip files at least.

ho1
great resource, thanks.
Jim Beam