@@ -44,7 +44,7 @@ public void Compress(string sourceDirectoryName
4444 foreach ( var toZipFileKey in toZipFileDictionaryList . Keys )
4545 {
4646 if ( toZipFileKey == destinationArchiveFileName ) continue ;
47-
47+
4848 var toZipedFileName = Path . GetFileName ( toZipFileKey ) ;
4949 var toDelArchives = new List < ZipArchiveEntry > ( ) ;
5050 foreach ( var zipArchiveEntry in archive . Entries )
@@ -84,8 +84,8 @@ public void Compress(string sourceDirectoryName
8484 var toDelArchives = new List < ZipArchiveEntry > ( ) ;
8585 foreach ( var zipArchiveEntry in archive . Entries )
8686 {
87- if ( toZipedFileName != null
88- && ( zipArchiveEntry . FullName . StartsWith ( toZipedFileName ) || toZipedFileName . StartsWith ( zipArchiveEntry . FullName ) ) )
87+ if ( toZipedFileName != null
88+ && ( zipArchiveEntry . FullName . StartsWith ( toZipedFileName ) || toZipedFileName . StartsWith ( zipArchiveEntry . FullName ) ) )
8989 {
9090 toDelArchives . Add ( zipArchiveEntry ) ;
9191 }
@@ -101,13 +101,13 @@ public void Compress(string sourceDirectoryName
101101 }
102102 }
103103 }
104- catch ( Exception exception )
104+ catch ( Exception exception )
105105 {
106106 Debug . WriteLine ( exception ) ;
107107 throw new Exception ( $ "Failed to compress archive: { exception . Message } ") ;
108108 }
109109 }
110-
110+
111111 /// <summary>
112112 /// Unzip the Zip file and save it to the specified target path folder .
113113 /// </summary>
@@ -120,7 +120,7 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
120120 {
121121 var dirSeparatorChar = Path . DirectorySeparatorChar . ToString ( ) ;
122122 unZipDir = unZipDir . EndsWith ( dirSeparatorChar ) ? unZipDir : unZipDir + dirSeparatorChar ;
123-
123+
124124 var directoryInfo = new DirectoryInfo ( unZipDir ) ;
125125 if ( ! directoryInfo . Exists )
126126 {
@@ -138,14 +138,14 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
138138 for ( int i = 0 ; i < archive . Entries . Count ; i ++ )
139139 {
140140 var entries = archive . Entries [ i ] ;
141- if ( entries . FullName . EndsWith ( dirSeparatorChar ) )
141+ var pattern = $ "^{ dirSeparatorChar } *";
142+ var entryFilePath = Regex . Replace ( entries . FullName . Replace ( "/" , dirSeparatorChar ) , pattern ,
143+ "" ) ;
144+ if ( entryFilePath . EndsWith ( dirSeparatorChar ) )
142145 {
143146 continue ;
144147 }
145148
146- var pattern = $ "^{ dirSeparatorChar } *";
147- var entryFilePath = Regex . Replace ( entries . FullName . Replace ( "/" , dirSeparatorChar ) , pattern ,
148- "" ) ;
149149 var filePath = directoryInfo + entryFilePath ;
150150 var greatFolder = Directory . GetParent ( filePath ) ;
151151 if ( greatFolder is not null && ! greatFolder . Exists )
0 commit comments