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?
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.
I do not know of a good tutorial but BinaryReader is a good place to start for reading on the "bits & bytes" level
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.
精彩评论