|
23 | 23 | using System.Text;
|
24 | 24 | using System.Xml;
|
25 | 25 | using System.Xml.XPath;
|
26 |
| -using Ionic.Zip; |
27 | 26 | using Newtonsoft.Json;
|
28 | 27 | using OpenQA.Selenium.Internal;
|
29 | 28 | using OpenQA.Selenium.Remote;
|
| 29 | +using System.IO.Compression; |
30 | 30 |
|
31 | 31 | namespace OpenQA.Selenium.Firefox
|
32 | 32 | {
|
@@ -195,10 +195,15 @@ public static FirefoxProfile FromBase64String(string base64)
|
195 | 195 | byte[] zipContent = Convert.FromBase64String(base64);
|
196 | 196 | using (MemoryStream zipStream = new MemoryStream(zipContent))
|
197 | 197 | {
|
198 |
| - using (ZipFile profileZipArchive = ZipFile.Read(zipStream)) |
| 198 | + using (ZipStorer profileZipArchive = ZipStorer.Open(zipStream, FileAccess.Read)) |
199 | 199 | {
|
200 |
| - profileZipArchive.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently; |
201 |
| - profileZipArchive.ExtractAll(destinationDirectory); |
| 200 | + List<ZipStorer.ZipFileEntry> entryList = profileZipArchive.ReadCentralDir(); |
| 201 | + foreach (ZipStorer.ZipFileEntry entry in entryList) |
| 202 | + { |
| 203 | + string fileName = entry.FilenameInZip.Replace('/', Path.DirectorySeparatorChar); |
| 204 | + string destinationFile = Path.Combine(destinationDirectory, fileName); |
| 205 | + profileZipArchive.ExtractFile(entry, destinationFile); |
| 206 | + } |
202 | 207 | }
|
203 | 208 | }
|
204 | 209 |
|
@@ -333,15 +338,20 @@ public string ToBase64String()
|
333 | 338 | {
|
334 | 339 | string base64zip = string.Empty;
|
335 | 340 | this.WriteToDisk();
|
336 |
| - using (ZipFile profileZipFile = new ZipFile()) |
| 341 | + |
| 342 | + using (MemoryStream profileMemoryStream = new MemoryStream()) |
337 | 343 | {
|
338 |
| - profileZipFile.AddDirectory(this.profileDir); |
339 |
| - using (MemoryStream profileMemoryStream = new MemoryStream()) |
| 344 | + using (ZipStorer profileZipArchive = ZipStorer.Create(profileMemoryStream, string.Empty)) |
340 | 345 | {
|
341 |
| - profileZipFile.Save(profileMemoryStream); |
342 |
| - base64zip = Convert.ToBase64String(profileMemoryStream.ToArray()); |
| 346 | + string[] files = Directory.GetFiles(this.profileDir, "*.*", SearchOption.AllDirectories); |
| 347 | + foreach (string file in files) |
| 348 | + { |
| 349 | + string fileNameInZip = file.Substring(this.profileDir.Length).Replace(Path.DirectorySeparatorChar, '/'); |
| 350 | + profileZipArchive.AddFile(ZipStorer.Compression.Deflate, file, fileNameInZip, string.Empty); |
| 351 | + } |
343 | 352 | }
|
344 | 353 |
|
| 354 | + base64zip = Convert.ToBase64String(profileMemoryStream.ToArray()); |
345 | 355 | this.Clean();
|
346 | 356 | }
|
347 | 357 |
|
|
0 commit comments