开发者

C# Primer or example on working with files on a granular level

开发者 https://www.devze.com 2022-12-31 13:41 出处:网络
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 p

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消