知识大全 c#2.0中新增的两个压缩类
Posted 知
篇首语:人还是要乐观,心碎了就对自己说,碎碎平安。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 c#2.0中新增的两个压缩类相关的知识,希望对你有一定的参考价值。
class clsZip public void CompressFile ( string sourceFile string destinationFile ) // make sure the source file is there if ( File Exists ( sourceFile ) == false ) throw new FileNotFoundException ( ); // Create the streams and byte arrays needed byte[] buffer = null; FileStream sourceStream = null; FileStream destinationStream = null; GZipStream pressedStream = null; try // Read the bytes from the source file into a byte array sourceStream = new FileStream ( sourceFile FileMode Open FileAccess Read FileShare Read ); // Read the source stream values into the buffer buffer = new byte[sourceStream Length]; int checkCounter = sourceStream Read ( buffer buffer Length ); if ( checkCounter != buffer Length ) throw new ApplicationException ( ); // Open the FileStream to write to destinationStream = new FileStream ( destinationFile FileMode OpenOrCreate FileAccess Write ); // Create a pression stream pointing to the destiantion stream pressedStream = new GZipStream ( destinationStream CompressionMode Compress true ); // Now write the pressed data to the destination file pressedStream Write ( buffer buffer Length ); catch ( ApplicationException ex ) MessageBox Show ( ex Message 压缩文件时发生错误 MessageBoxButtons OK MessageBoxIcon Error ); finally // Make sure we allways close all streams if ( sourceStream != null ) sourceStream Close ( ); if ( pressedStream != null ) pressedStream Close ( ); if ( destinationStream != null ) destinationStream Close ( ); public void DepressFile ( string sourceFile string destinationFile ) // make sure the source file is there if ( File Exists ( sourceFile ) == false ) throw new FileNotFoundException ( ); // Create the streams and byte arrays needed FileStream sourceStream = null; FileStream destinationStream = null; GZipStream depressedStream = null; byte[] quartetBuffer = null; try // Read in the pressed source stream sourceStream = new FileStream ( sourceFile FileMode Open ); // Create a pression stream pointing to the destiantion stream depressedStream = new GZipStream ( sourceStream CompressionMode Depress true ); // Read the footer to determine the length of the destiantion file quartetBuffer = new byte[ ]; int position = (int)sourceStream Length ; sourceStream Position = position; sourceStream Read ( quartetBuffer ); sourceStream Position = ; int checkLength = BitConverter ToInt ( quartetBuffer ); byte[] buffer = new byte[checkLength + ]; int offset = ; int total = ; // Read the pressed data into the buffer while ( true ) int bytesRead = depressedStream Read ( buffer offset ); if ( bytesRead == ) break; offset += bytesRead; total += bytesRead; // Now write everything to the destination file destinationStream = new FileStream ( destinationFile FileMode Create ); destinationStream Write ( buffer total ); // and flush everyhting to clean out the buffer destinationStream Flush ( ); catch ( ApplicationException ex ) MessageBox Show(ex Message 解压文件时发生错误 MessageBoxButtons OK MessageBoxIcon Error); finally // Make sure we allways close all streams if ( sourceStream != null ) sourceStream Close ( ); if ( depressedStream != null ) depressedStream Close ( ); if ( destinationStream != null ) destinationStream Close ( ); cha138/Article/program/net/201311/12971相关参考
C#2.0局部类型、空属类型、静态类[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 局部类
C#2.0局部类型、空属类型、静态类[2] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 局部类
C#2.0局部类型、空属类型、静态类[3] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 局部类
Java1.5中新的静态导入特性 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 要导入一个类或接
如何用CZip/CUnzip类压缩/解压缩文件 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!Zip
根据我国宪法修正案,在爱国统一战线中新增加的社会阶层是_____A、社会主义劳动者B、社会主义事业的建设者C、拥护社会主义的爱国者D、拥护祖国统一的爱国者答案:B解析:2004年《宪法修正案》第19条
价跌量增的情形这主要有三种情形:1.在股指或股价连跌数日后,若股指或股价轻微续跌而成交量剧增,则意味着股指或股价已落入底部,此时,是选择投资购股的时机。2.在股指或股价开始下跌时,成交量放大,同时,收
新三板定增的内容又称新三板定向发行,是挂牌公司在挂牌后进行定向发行股票融资,可申请一次核准,分期发行。发行股票后股东累计不超过200人的,或者在一年内发行股票累计融资额低于公司净资产的20%的,豁免向
参与新三板定增的原因(1)新三板作为股权转让系统,其交易功能尚还不发达。在协议转让方式下,新三板市场整体交易量稀少,投资者很难获得买入的机会。未来定向增发会是新三板企业股票融资的主流方式。投资者通过参
新《安全生产法》规定,生产经营单位对从业人员进行安全生产教育和培训中新增内容有()。
新《安全生产法》规定,生产经营单位对从业人员进行安全生产教育和培训中新增内容有()。A.保证从业人员具备必要的安全生产知识B.熟悉有关的安全生产规章制度和安全操作规程C.掌握本岗位的安全操作技能D.了