HTML5技术

最好的.NET开源免费ZIP库DotNetZip(.NET组件介绍之三) - 彭泽0902(2)

字号+ 作者:H5之家 来源:H5之家 2016-12-08 11:00 我要评论( )

IsZipFile(Stream stream, bool testExtract){ if (stream == null ){ );} bool flag = false ; try { if (! stream.CanRead){ return false ;}Stream @null = Stream.Null; using (ZipFile file = Read(stream, nu

IsZipFile(Stream stream, bool testExtract) { if (stream == null) { ); } bool flag = false; try { if (!stream.CanRead) { return false; } Stream @null = Stream.Null; using (ZipFile file = Read(stream, null, null, null)) { if (testExtract) { foreach (ZipEntry entry in file) { if (!entry.IsDirectory) { entry.Extract(@null); } } } } flag = true; } catch (IOException) { } catch (ZipException) { } return flag; }

 2.Read()读取数据流:

private static ZipFile Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler<ReadProgressEventArgs> readProgress) { if (zipStream == null) { ); } ZipFile zf = new ZipFile { _StatusMessageTextWriter = statusMessageWriter, _alternateEncoding = encoding ?? DefaultEncoding, _alternateEncodingUsage = ZipOption.Always }; if (readProgress != null) { zf.ReadProgress += readProgress; } zf._readstream = (zipStream.Position == 0L) ? zipStream : new OffsetStream(zipStream); zf._ReadStreamIsOurs = false; if (zf.Verbose) { zf._StatusMessageTextWriter.WriteLine(); } ReadIntoInstance(zf); return zf; }

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 高品质开源工具Chloe.ORM:支持存储过程与Oracle - 我叫So

    高品质开源工具Chloe.ORM:支持存储过程与Oracle - 我叫So

    2016-12-08 12:00

  • 移动Web触摸与运动解决方案AlloyTouch开源啦 - 【当耐特】

    移动Web触摸与运动解决方案AlloyTouch开源啦 - 【当耐特】

    2016-12-07 15:00

  • 腾讯AlloyTeam移动Web裁剪组件AlloyCrop正式开源 - 【当耐特】

    腾讯AlloyTeam移动Web裁剪组件AlloyCrop正式开源 - 【当耐特】

    2016-11-21 13:00

  • ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑 - 路过秋天

    ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑

    2016-11-20 16:00

网友点评
v