懒得勤快 %!s(int64=6) %!d(string=hai) anos
pai
achega
8036b717f6

+ 54 - 0
Masuit.Tools.Core/Files/ClassZip.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// ClassZip
+    /// </summary>
+    [Obsolete("该类已过时,请使用SevenZipCompressor替代")]
+    public static class ClassZip
+    {
+        #region 压缩
+
+        /// <summary>
+        /// 压缩
+        /// </summary>
+        /// <param name="fileToZip">待压缩的文件目录或文件</param>
+        /// <param name="zipedFile">生成的目标文件</param>
+        /// <param name="level">压缩级别,默认值6</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static bool Zip(string fileToZip, string zipedFile, int level = 6)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        /// <summary>
+        /// 将多个文件压缩到一个文件流中,可保存为zip文件,方便于web方式下载
+        /// </summary>
+        /// <param name="files">多个文件路径,文件或文件夹</param>
+        /// <returns>文件流</returns>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代")]
+        public static byte[] ZipStream(List<string> files)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代");
+        }
+
+        #endregion
+
+        #region 解压
+
+        /// <summary>
+        /// 解压
+        /// </summary>
+        /// <param name="fileToUpZip">待解压的文件</param>
+        /// <param name="zipedFolder">解压目标存放目录</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static void UnZip(string fileToUpZip, string zipedFolder)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        #endregion
+    }
+}

+ 8 - 0
Masuit.Tools.Core/Files/ISevenZipCompressor.cs

@@ -16,6 +16,14 @@ namespace Masuit.Tools.Files
         /// <param name="ignoreEmptyDir">忽略空文件夹</param>
         void Decompress(string compressedFile, string dir = "", bool ignoreEmptyDir = true);
 
+        /// <summary>
+        /// 解压文件,自动检测压缩包类型
+        /// </summary>
+        /// <param name="compressedFile">rar文件</param>
+        /// <param name="dir">解压到...</param>
+        /// <param name="ignoreEmptyDir">忽略空文件夹</param>
+        void Extract(string compressedFile, string dir = "", bool ignoreEmptyDir = true);
+
         /// <summary>
         /// 解压rar文件
         /// </summary>

+ 9 - 198
Masuit.Tools.Core/Files/Compress.cs → Masuit.Tools.Core/Files/SevenZipCompressor.cs

@@ -1,5 +1,4 @@
-using Microsoft.Win32;
-using SharpCompress.Archives;
+using SharpCompress.Archives;
 using SharpCompress.Archives.Rar;
 using SharpCompress.Archives.Zip;
 using SharpCompress.Common;
@@ -7,7 +6,6 @@ using SharpCompress.Readers;
 using SharpCompress.Writers;
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Net.Http;
@@ -104,6 +102,14 @@ namespace Masuit.Tools.Files
             }
         }
 
+        /// <summary>
+        /// 解压文件,自动检测压缩包类型
+        /// </summary>
+        /// <param name="compressedFile">rar文件</param>
+        /// <param name="dir">解压到...</param>
+        /// <param name="ignoreEmptyDir">忽略空文件夹</param>
+        public void Extract(string compressedFile, string dir = "", bool ignoreEmptyDir = true) => Decompress(compressedFile, dir, ignoreEmptyDir);
+
         /// <summary>
         /// 解压文件,自动检测压缩包类型
         /// </summary>
@@ -250,199 +256,4 @@ namespace Masuit.Tools.Files
             return dic;
         }
     }
-
-    /// <summary>
-    /// SharpZip
-    /// </summary>
-    public static class SharpZip
-    {
-        #region 文件压缩
-
-        /// <summary>
-        /// 文件压缩
-        /// </summary> 
-        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
-        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static void PackFiles(string filename, string directory)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        /// <summary>
-        /// 文件压缩
-        /// </summary> 
-        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
-        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static async void PackFilesAsync(string filename, string directory)
-        {
-            await Task.Delay(0);
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        #endregion
-
-        #region 文件解压缩
-
-        /// <summary>
-        /// 文件解压缩
-        /// </summary>
-        /// <param name="file">待解压文件名(包含物理路径)</param>
-        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static bool UnpackFiles(string file, string dir)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        /// <summary>
-        /// 文件解压缩
-        /// </summary>
-        /// <param name="file">待解压文件名(包含物理路径)</param>
-        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static async Task<bool> UnpackFilesAsync(string file, string dir)
-        {
-            await Task.Delay(0);
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        #endregion
-    }
-
-    /// <summary>
-    /// ClassZip
-    /// </summary>
-    public static class ClassZip
-    {
-        #region 压缩
-
-        /// <summary>
-        /// 压缩
-        /// </summary>
-        /// <param name="fileToZip">待压缩的文件目录或文件</param>
-        /// <param name="zipedFile">生成的目标文件</param>
-        /// <param name="level">压缩级别,默认值6</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static bool Zip(string fileToZip, string zipedFile, int level = 6)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        /// <summary>
-        /// 将多个文件压缩到一个文件流中,可保存为zip文件,方便于web方式下载
-        /// </summary>
-        /// <param name="files">多个文件路径,文件或文件夹</param>
-        /// <returns>文件流</returns>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代")]
-        public static byte[] ZipStream(List<string> files)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代");
-        }
-
-        #endregion
-
-        #region 解压
-
-        /// <summary>
-        /// 解压
-        /// </summary>
-        /// <param name="fileToUpZip">待解压的文件</param>
-        /// <param name="zipedFolder">解压目标存放目录</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static void UnZip(string fileToUpZip, string zipedFolder)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        #endregion
-    }
-
-    /// <summary>
-    /// WinRAR压缩操作
-    /// </summary>
-    public static class WinrarHelper
-    {
-        #region 压缩
-
-        /// <summary>
-        /// 压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要压缩的文件目录</param>
-        /// <param name="dirpath">初始目录</param>
-        public static void Rar(string zipname, string zippath, string dirpath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg?.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " a  " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden,
-                WorkingDirectory = dirpath
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 解压缩
-
-        /// <summary>
-        /// 解压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要解压的文件路径</param>
-        public static void UnRar(string zipname, string zippath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " X " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 私有变量
-
-        private static string _theRar;
-        private static RegistryKey _theReg;
-        private static object _theObj;
-        private static string _theInfo;
-        private static ProcessStartInfo _theStartInfo;
-        private static Process _theProcess;
-
-        #endregion
-    }
 }

+ 66 - 0
Masuit.Tools.Core/Files/SharpZip.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// SharpZip
+    /// </summary>
+    [Obsolete("该类已过时,请使用SevenZipCompressor替代")]
+    public static class SharpZip
+    {
+        #region 文件压缩
+
+        /// <summary>
+        /// 文件压缩
+        /// </summary> 
+        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
+        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static void PackFiles(string filename, string directory)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        /// <summary>
+        /// 文件压缩
+        /// </summary> 
+        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
+        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static async void PackFilesAsync(string filename, string directory)
+        {
+            await Task.Delay(0);
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        #endregion
+
+        #region 文件解压缩
+
+        /// <summary>
+        /// 文件解压缩
+        /// </summary>
+        /// <param name="file">待解压文件名(包含物理路径)</param>
+        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static bool UnpackFiles(string file, string dir)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        /// <summary>
+        /// 文件解压缩
+        /// </summary>
+        /// <param name="file">待解压文件名(包含物理路径)</param>
+        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static async Task<bool> UnpackFilesAsync(string file, string dir)
+        {
+            await Task.Delay(0);
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        #endregion
+    }
+}

+ 92 - 0
Masuit.Tools.Core/Files/WinrarHelper.cs

@@ -0,0 +1,92 @@
+using System.Diagnostics;
+using Microsoft.Win32;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// WinRAR压缩操作
+    /// </summary>
+    public static class WinrarHelper
+    {
+        #region 压缩
+
+        /// <summary>
+        /// 压缩
+        /// </summary>
+        /// <param name="zipname">要解压的文件名</param>
+        /// <param name="zippath">要压缩的文件目录</param>
+        /// <param name="dirpath">初始目录</param>
+        public static void Rar(string zipname, string zippath, string dirpath)
+        {
+            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
+            if (_theReg != null)
+            {
+                _theObj = _theReg.GetValue("");
+                _theRar = _theObj.ToString();
+                _theReg?.Close();
+            }
+
+            _theRar = _theRar.Substring(1, _theRar.Length - 7);
+            _theInfo = " a  " + zipname + " " + zippath;
+            _theStartInfo = new ProcessStartInfo
+            {
+                FileName = _theRar,
+                Arguments = _theInfo,
+                WindowStyle = ProcessWindowStyle.Hidden,
+                WorkingDirectory = dirpath
+            };
+            _theProcess = new Process
+            {
+                StartInfo = _theStartInfo
+            };
+            _theProcess.Start();
+        }
+
+        #endregion
+
+        #region 解压缩
+
+        /// <summary>
+        /// 解压缩
+        /// </summary>
+        /// <param name="zipname">要解压的文件名</param>
+        /// <param name="zippath">要解压的文件路径</param>
+        public static void UnRar(string zipname, string zippath)
+        {
+            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
+            if (_theReg != null)
+            {
+                _theObj = _theReg.GetValue("");
+                _theRar = _theObj.ToString();
+                _theReg.Close();
+            }
+
+            _theRar = _theRar.Substring(1, _theRar.Length - 7);
+            _theInfo = " X " + zipname + " " + zippath;
+            _theStartInfo = new ProcessStartInfo
+            {
+                FileName = _theRar,
+                Arguments = _theInfo,
+                WindowStyle = ProcessWindowStyle.Hidden
+            };
+            _theProcess = new Process
+            {
+                StartInfo = _theStartInfo
+            };
+            _theProcess.Start();
+        }
+
+        #endregion
+
+        #region 私有变量
+
+        private static string _theRar;
+        private static RegistryKey _theReg;
+        private static object _theObj;
+        private static string _theInfo;
+        private static ProcessStartInfo _theStartInfo;
+        private static Process _theProcess;
+
+        #endregion
+    }
+}

+ 3 - 2
Masuit.Tools.UnitTest/Masuit.Tools.UnitTest.csproj

@@ -64,8 +64,8 @@
     <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
     <Reference Include="System.Net.Http" />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
     </Reference>
     <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
@@ -126,6 +126,7 @@
     <Compile Include="TestClasses\TestClassA.cs" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="app.config" />
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>

+ 11 - 0
Masuit.Tools.UnitTest/app.config

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 1 - 1
Masuit.Tools.UnitTest/packages.config

@@ -9,7 +9,7 @@
   <package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net461" />
   <package id="MSTest.TestFramework" version="1.4.0" targetFramework="net461" />
   <package id="NUnit" version="3.11.0" targetFramework="net461" />
-  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net461" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" />
   <package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net461" />
   <package id="xunit" version="2.4.1" targetFramework="net461" />
   <package id="xunit.abstractions" version="2.0.3" targetFramework="net461" />

+ 54 - 0
Masuit.Tools/Files/ClassZip.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// ClassZip
+    /// </summary>
+    [Obsolete("该类已过时,请使用SevenZipCompressor替代")]
+    public static class ClassZip
+    {
+        #region 压缩
+
+        /// <summary>
+        /// 压缩
+        /// </summary>
+        /// <param name="fileToZip">待压缩的文件目录或文件</param>
+        /// <param name="zipedFile">生成的目标文件</param>
+        /// <param name="level">压缩级别,默认值6</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static bool Zip(string fileToZip, string zipedFile, int level = 6)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        /// <summary>
+        /// 将多个文件压缩到一个文件流中,可保存为zip文件,方便于web方式下载
+        /// </summary>
+        /// <param name="files">多个文件路径,文件或文件夹</param>
+        /// <returns>文件流</returns>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代")]
+        public static byte[] ZipStream(List<string> files)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代");
+        }
+
+        #endregion
+
+        #region 解压
+
+        /// <summary>
+        /// 解压
+        /// </summary>
+        /// <param name="fileToUpZip">待解压的文件</param>
+        /// <param name="zipedFolder">解压目标存放目录</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static void UnZip(string fileToUpZip, string zipedFolder)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        #endregion
+    }
+}

+ 9 - 198
Masuit.Tools/Files/Compress.cs → Masuit.Tools/Files/SevenZipCompressor.cs

@@ -1,5 +1,4 @@
-using Microsoft.Win32;
-using SharpCompress.Archives;
+using SharpCompress.Archives;
 using SharpCompress.Archives.Rar;
 using SharpCompress.Archives.Zip;
 using SharpCompress.Common;
@@ -7,7 +6,6 @@ using SharpCompress.Readers;
 using SharpCompress.Writers;
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Net.Http;
@@ -93,6 +91,14 @@ namespace Masuit.Tools.Files
             }
         }
 
+        /// <summary>
+        /// 解压文件,自动检测压缩包类型
+        /// </summary>
+        /// <param name="compressedFile">rar文件</param>
+        /// <param name="dir">解压到...</param>
+        /// <param name="ignoreEmptyDir">忽略空文件夹</param>
+        public static void Extract(string compressedFile, string dir = "", bool ignoreEmptyDir = true) => Decompress(compressedFile, dir, ignoreEmptyDir);
+
         /// <summary>
         /// 解压文件,自动检测压缩包类型
         /// </summary>
@@ -242,199 +248,4 @@ namespace Masuit.Tools.Files
             return dic;
         }
     }
-
-    /// <summary>
-    /// SharpZip
-    /// </summary>
-    public static class SharpZip
-    {
-        #region 文件压缩
-
-        /// <summary>
-        /// 文件压缩
-        /// </summary> 
-        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
-        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static void PackFiles(string filename, string directory)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        /// <summary>
-        /// 文件压缩
-        /// </summary> 
-        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
-        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static async void PackFilesAsync(string filename, string directory)
-        {
-            await Task.Delay(0);
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        #endregion
-
-        #region 文件解压缩
-
-        /// <summary>
-        /// 文件解压缩
-        /// </summary>
-        /// <param name="file">待解压文件名(包含物理路径)</param>
-        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static bool UnpackFiles(string file, string dir)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        /// <summary>
-        /// 文件解压缩
-        /// </summary>
-        /// <param name="file">待解压文件名(包含物理路径)</param>
-        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static async Task<bool> UnpackFilesAsync(string file, string dir)
-        {
-            await Task.Delay(0);
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        #endregion
-    }
-
-    /// <summary>
-    /// ClassZip
-    /// </summary>
-    public static class ClassZip
-    {
-        #region 压缩
-
-        /// <summary>
-        /// 压缩
-        /// </summary>
-        /// <param name="fileToZip">待压缩的文件目录或文件</param>
-        /// <param name="zipedFile">生成的目标文件</param>
-        /// <param name="level">压缩级别,默认值6</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
-        public static bool Zip(string fileToZip, string zipedFile, int level = 6)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
-        }
-
-        /// <summary>
-        /// 将多个文件压缩到一个文件流中,可保存为zip文件,方便于web方式下载
-        /// </summary>
-        /// <param name="files">多个文件路径,文件或文件夹</param>
-        /// <returns>文件流</returns>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代")]
-        public static byte[] ZipStream(List<string> files)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.ZipStream方法替代");
-        }
-
-        #endregion
-
-        #region 解压
-
-        /// <summary>
-        /// 解压
-        /// </summary>
-        /// <param name="fileToUpZip">待解压的文件</param>
-        /// <param name="zipedFolder">解压目标存放目录</param>
-        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
-        public static void UnZip(string fileToUpZip, string zipedFolder)
-        {
-            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
-        }
-
-        #endregion
-    }
-
-    /// <summary>
-    /// WinRAR压缩操作
-    /// </summary>
-    public static class WinrarHelper
-    {
-        #region 压缩
-
-        /// <summary>
-        /// 压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要压缩的文件目录</param>
-        /// <param name="dirpath">初始目录</param>
-        public static void Rar(string zipname, string zippath, string dirpath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg?.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " a  " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden,
-                WorkingDirectory = dirpath
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 解压缩
-
-        /// <summary>
-        /// 解压缩
-        /// </summary>
-        /// <param name="zipname">要解压的文件名</param>
-        /// <param name="zippath">要解压的文件路径</param>
-        public static void UnRar(string zipname, string zippath)
-        {
-            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
-            if (_theReg != null)
-            {
-                _theObj = _theReg.GetValue("");
-                _theRar = _theObj.ToString();
-                _theReg.Close();
-            }
-
-            _theRar = _theRar.Substring(1, _theRar.Length - 7);
-            _theInfo = " X " + zipname + " " + zippath;
-            _theStartInfo = new ProcessStartInfo
-            {
-                FileName = _theRar,
-                Arguments = _theInfo,
-                WindowStyle = ProcessWindowStyle.Hidden
-            };
-            _theProcess = new Process
-            {
-                StartInfo = _theStartInfo
-            };
-            _theProcess.Start();
-        }
-
-        #endregion
-
-        #region 私有变量
-
-        private static string _theRar;
-        private static RegistryKey _theReg;
-        private static object _theObj;
-        private static string _theInfo;
-        private static ProcessStartInfo _theStartInfo;
-        private static Process _theProcess;
-
-        #endregion
-    }
 }

+ 66 - 0
Masuit.Tools/Files/SharpZip.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// SharpZip
+    /// </summary>
+    [Obsolete("该类已过时,请使用SevenZipCompressor替代")]
+    public static class SharpZip
+    {
+        #region 文件压缩
+
+        /// <summary>
+        /// 文件压缩
+        /// </summary> 
+        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
+        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static void PackFiles(string filename, string directory)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        /// <summary>
+        /// 文件压缩
+        /// </summary> 
+        /// <param name="filename"> 压缩后的文件名(包含物理路径)</param>
+        /// <param name="directory">待压缩的文件夹(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Zip方法替代")]
+        public static async void PackFilesAsync(string filename, string directory)
+        {
+            await Task.Delay(0);
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Zip方法替代");
+        }
+
+        #endregion
+
+        #region 文件解压缩
+
+        /// <summary>
+        /// 文件解压缩
+        /// </summary>
+        /// <param name="file">待解压文件名(包含物理路径)</param>
+        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static bool UnpackFiles(string file, string dir)
+        {
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        /// <summary>
+        /// 文件解压缩
+        /// </summary>
+        /// <param name="file">待解压文件名(包含物理路径)</param>
+        /// <param name="dir"> 解压到哪个目录中(包含物理路径)</param>
+        [Obsolete("该方法已过时,请使用SevenZipCompressor.Decompress方法替代")]
+        public static async Task<bool> UnpackFilesAsync(string file, string dir)
+        {
+            await Task.Delay(0);
+            throw new NotImplementedException("该方法已过时,请使用SevenZipCompressor.Decompress方法替代");
+        }
+
+        #endregion
+    }
+}

+ 92 - 0
Masuit.Tools/Files/WinrarHelper.cs

@@ -0,0 +1,92 @@
+using System.Diagnostics;
+using Microsoft.Win32;
+
+namespace Masuit.Tools.Files
+{
+    /// <summary>
+    /// WinRAR压缩操作
+    /// </summary>
+    public static class WinrarHelper
+    {
+        #region 压缩
+
+        /// <summary>
+        /// 压缩
+        /// </summary>
+        /// <param name="zipname">要解压的文件名</param>
+        /// <param name="zippath">要压缩的文件目录</param>
+        /// <param name="dirpath">初始目录</param>
+        public static void Rar(string zipname, string zippath, string dirpath)
+        {
+            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
+            if (_theReg != null)
+            {
+                _theObj = _theReg.GetValue("");
+                _theRar = _theObj.ToString();
+                _theReg?.Close();
+            }
+
+            _theRar = _theRar.Substring(1, _theRar.Length - 7);
+            _theInfo = " a  " + zipname + " " + zippath;
+            _theStartInfo = new ProcessStartInfo
+            {
+                FileName = _theRar,
+                Arguments = _theInfo,
+                WindowStyle = ProcessWindowStyle.Hidden,
+                WorkingDirectory = dirpath
+            };
+            _theProcess = new Process
+            {
+                StartInfo = _theStartInfo
+            };
+            _theProcess.Start();
+        }
+
+        #endregion
+
+        #region 解压缩
+
+        /// <summary>
+        /// 解压缩
+        /// </summary>
+        /// <param name="zipname">要解压的文件名</param>
+        /// <param name="zippath">要解压的文件路径</param>
+        public static void UnRar(string zipname, string zippath)
+        {
+            _theReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
+            if (_theReg != null)
+            {
+                _theObj = _theReg.GetValue("");
+                _theRar = _theObj.ToString();
+                _theReg.Close();
+            }
+
+            _theRar = _theRar.Substring(1, _theRar.Length - 7);
+            _theInfo = " X " + zipname + " " + zippath;
+            _theStartInfo = new ProcessStartInfo
+            {
+                FileName = _theRar,
+                Arguments = _theInfo,
+                WindowStyle = ProcessWindowStyle.Hidden
+            };
+            _theProcess = new Process
+            {
+                StartInfo = _theStartInfo
+            };
+            _theProcess.Start();
+        }
+
+        #endregion
+
+        #region 私有变量
+
+        private static string _theRar;
+        private static RegistryKey _theReg;
+        private static object _theObj;
+        private static string _theInfo;
+        private static ProcessStartInfo _theStartInfo;
+        private static Process _theProcess;
+
+        #endregion
+    }
+}

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

@@ -52,6 +52,7 @@
       <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="SharpCompress, Version=0.22.0.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
       <HintPath>..\packages\SharpCompress.0.22.0\lib\net45\SharpCompress.dll</HintPath>
     </Reference>
     <Reference Include="StackExchange.Redis, Version=1.2.6.0, Culture=neutral, processorArchitecture=MSIL">
@@ -97,10 +98,13 @@
     <Compile Include="DateTimeExt\DateInfoStruct.cs" />
     <Compile Include="DateTimeExt\TimeHelper.cs" />
     <Compile Include="DateTimeExt\WeekHolidayStruct.cs" />
+    <Compile Include="Files\ClassZip.cs" />
+    <Compile Include="Files\SharpZip.cs" />
+    <Compile Include="Files\WinrarHelper.cs" />
     <Compile Include="Mapping\EnumerableCopier.cs" />
     <Compile Include="Mapping\ExpressionGenericMapper.cs" />
     <Compile Include="Extensions.cs" />
-    <Compile Include="Files\Compress.cs" />
+    <Compile Include="Files\SevenZipCompressor.cs" />
     <Compile Include="Files\ExtensionAttach.cs" />
     <Compile Include="Files\INIFile.cs" />
     <Compile Include="Hardware\CpuInfo.cs" />

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 8
Test/Program.cs


+ 1 - 0
Test/Test.csproj

@@ -46,6 +46,7 @@
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.IO.Compression" />
+    <Reference Include="System.Web" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Program.cs" />

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio