zoukankan      html  css  js  c++  java
  • SharpZipLib 压缩后传输给第三方平台无法识别问题

    问题描述:在项目中需要将文件压缩然后传输给三方进行彩信发送,使用SharpZipLib 进行压缩,原先使用J#进行压缩处理,但是用SharpZipLib压缩后的zip文件传输过去之后,总会报发送失败。最后在加入 s.UseZip64 = UseZip64.Off;这一句话后,解决问题。特此记录。

    using (ZipOutputStream s = new ZipOutputStream(File.Create(argZipPath)))
                    {
                        s.UseZip64 = UseZip64.Off;
                        s.SetLevel(9); // 0 - store only to 9 - means best compression
                        byte[] buffer = new byte[4096];
                        foreach (string file in argFiles)
                        {
                            // Using GetFileName makes the result compatible with XP
                            // as the resulting path is not absolute.
                            ZipEntry entry = new ZipEntry(Path.GetFileName(file));
                            // Setup the entry data as required.
    
                            // Crc and size are handled by the library for seakable streams
                            // so no need to do them here.
                            // Could also use the last write time or similar for the file.
                            entry.DateTime = DateTime.Now;
                            s.PutNextEntry(entry);
    
                            using (FileStream fs = File.OpenRead(file))
                            {
                                int sourceBytes;
                                do
                                {
                                    sourceBytes = fs.Read(buffer, 0, buffer.Length);
                                    s.Write(buffer, 0, sourceBytes);
                                } while (sourceBytes > 0);
                            }
                        }
    
                        s.Finish();
                        s.Close();
                    }
    

      

  • 相关阅读:
    [转]Massive Model Rendering Techniques
    OpenCASCADE Texture Mapping
    RvmTranslator6.1
    Virtual Reality: Immersive Yourself In Your 3D Mockup
    OpenCascade Sweep Algorithm
    OpenCASCADE Trihedron Law
    OpenCascade Law Function
    javascript函数式编程和链式优化
    尾调用和尾递归
    箭头函数
  • 原文地址:https://www.cnblogs.com/gonganruyi/p/4169670.html
Copyright © 2011-2022 走看看