Browse Source

修正压缩zip时的bug

懒得勤快 6 năm trước cách đây
mục cha
commit
bf0c1f21d0

+ 2 - 1
Masuit.Tools.Core/Files/Compress.cs

@@ -206,7 +206,8 @@ namespace Masuit.Tools.Files
                 f.NameTransform = new ZipNameTransform(dirname); //通过这个名称格式化器,可以将里面的文件名进行一些处理。默认情况下,会自动根据文件的路径在zip中创建有关的文件夹。  
                 fileList.ForEach(s =>
                 {
-                    f.Add(s);
+                    f.Add(new StaticDiskDataSource(s), Path.GetFileName(s), CompressionMethod.Deflated, true);
+                    //f.Add(s);
                 });
                 f.CommitUpdate();
                 buffer = new byte[ms.Length];

+ 1 - 1
Masuit.Tools.Core/Masuit.Tools.Core.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.2.2.1</Version>
+    <Version>2.2.2.2</Version>
     <Authors>懒得勤快</Authors>
     <Company>masuit.com</Company>
     <Description>包含一些常用的操作类,大都是静态类,加密解密,反射操作,硬件信息,字符串扩展方法,日期时间扩展操作,大文件拷贝,图像裁剪,html处理,验证码、NoSql等常用封装。

+ 6 - 5
Masuit.Tools/Files/Compress.cs

@@ -1,11 +1,11 @@
-using System;
+using ICSharpCode.SharpZipLib.Checksum;
+using ICSharpCode.SharpZipLib.Zip;
+using Microsoft.Win32;
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Threading.Tasks;
-using ICSharpCode.SharpZipLib.Checksum;
-using ICSharpCode.SharpZipLib.Zip;
-using Microsoft.Win32;
 
 namespace Masuit.Tools.Files
 {
@@ -206,7 +206,8 @@ namespace Masuit.Tools.Files
                 f.NameTransform = new ZipNameTransform(dirname); //通过这个名称格式化器,可以将里面的文件名进行一些处理。默认情况下,会自动根据文件的路径在zip中创建有关的文件夹。  
                 fileList.ForEach(s =>
                 {
-                    f.Add(s);
+                    f.Add(new StaticDiskDataSource(s), Path.GetFileName(s), CompressionMethod.Deflated, true);
+                    //f.Add(s);
                 });
                 f.CommitUpdate();
                 buffer = new byte[ms.Length];

+ 2 - 2
Masuit.Tools/Properties/AssemblyInfo.cs

@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
 // 方法是按如下所示使用“*”: :
 // [assembly: AssemblyVersion("1.0.*")]
 
-[assembly: AssemblyVersion("2.2.2.0")]
-[assembly: AssemblyFileVersion("2.2.2.0")]
+[assembly: AssemblyVersion("2.2.2.2")]
+[assembly: AssemblyFileVersion("2.2.2.2")]
 [assembly: NeutralResourcesLanguage("zh-CN")]
 

+ 11 - 30
Test/Program.cs

@@ -1,5 +1,6 @@
-using System.Collections.Generic;
-using System.Linq.Expressions;
+using Masuit.Tools.Files;
+using System.Collections.Generic;
+using System.IO;
 
 namespace Test
 {
@@ -7,34 +8,14 @@ namespace Test
     {
         static void Main(string[] args)
         {
-            //double time = HiPerfTimer.Execute(() =>
-            //{
-            //    for (int i = 0; i < 1000000; i++)
-            //    {
-            //        A a = new A()
-            //        {
-            //            C = new C()
-            //            {
-            //                MyProperty = "c"
-            //            },
-            //            List = new List<C>()
-            //            {
-            //                new C()
-            //                {
-            //                    MyProperty = "cc",
-            //                    Obj = new D()
-            //                    {
-            //                        MyProperty = "dd"
-            //                    }
-            //                }
-            //            }
-            //        };
-            //        var b = a.Map<A, B>();
-            //    }
-            //});
-            //Console.WriteLine(time);
-            NewExpression newExpression = Expression.New(typeof(int[]));
-
+            byte[] bytes = ClassZip.ZipStream(new List<string>()
+            {
+                @"D:\vsix2017\ReSharper\JetBrains Resharper 2018.3 Patch\JetBrains Resharper 2018.2.x AutoPatch.cmd",
+                @"D:\vsix2017\ReSharper\JetBrains Resharper 2018.3 Patch\JetBrains Resharper 2018.3 Patch.cmd",
+                @"D:\vsix2017\ReSharper\JetBrains Resharper 2018.3 Patch\sfk190.exe",
+            });
+            FileStream fs = new FileStream(@"D:\1.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite);
+            fs.Write(bytes, 0, bytes.Length);
         }
     }