|
1 | 1 | using System; |
2 | 2 | using System.Diagnostics; |
3 | 3 | using System.IO; |
| 4 | +using System.IO.Compression; |
4 | 5 | using System.Windows; |
5 | 6 | using System.Windows.Input; |
6 | 7 |
|
@@ -39,19 +40,33 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e) |
39 | 40 | { |
40 | 41 | using (MemoryStream unmStream = new MemoryStream(ModApi.Updater.Properties.Resources.ModApiUpdate)) |
41 | 42 | { |
42 | | - using (ZipStorer archive = ZipStorer.Open(unmStream, FileAccess.Read, true)) |
| 43 | + string unm = Environment.ExpandEnvironmentVariables(@"%appdata%\ModAPITemp.zip"); |
| 44 | + if (File.Exists(unm)) |
| 45 | + File.Delete(unm); |
| 46 | + |
| 47 | + using (var file = File.Create(unm)) |
| 48 | + { |
| 49 | + unmStream.Seek(0, SeekOrigin.Begin); |
| 50 | + unmStream.CopyTo(file); |
| 51 | + } |
| 52 | + |
| 53 | + using (ZipArchive archive = ZipFile.Open(unm, ZipArchiveMode.Update)) |
43 | 54 | { |
44 | | - InstallProgressBar.Maximum = archive.ReadCentralDir().Count; |
| 55 | + InstallProgressBar.Maximum = archive.Entries.Count; |
45 | 56 |
|
46 | | - foreach (ZipStorer.ZipFileEntry s in archive.ReadCentralDir()) |
| 57 | + foreach (var s in archive.Entries) |
47 | 58 | { |
48 | | - string fileOutPath = Path.Combine(path, s.FilenameInZip); |
| 59 | + string fileOutPath = Path.Combine(path, s.FullName); |
49 | 60 |
|
50 | 61 | if (File.Exists(fileOutPath)) |
51 | 62 | File.Delete(fileOutPath); |
52 | 63 |
|
53 | | - if (IsPathNotPartOfConfiguration(fileOutPath)) |
54 | | - archive.ExtractFile(s, fileOutPath); |
| 64 | + if (!s.FullName.EndsWith("/") && |
| 65 | + !s.FullName.EndsWith("\\") && |
| 66 | + IsPathNotPartOfConfiguration(fileOutPath)) |
| 67 | + { |
| 68 | + s.ExtractToFile(fileOutPath); |
| 69 | + } |
55 | 70 |
|
56 | 71 | if (InstallProgressBar.Value < InstallProgressBar.Maximum) |
57 | 72 | InstallProgressBar.Value++; |
|
0 commit comments