public static OpenRead ( string archiveFileName ) : |
||
archiveFileName | string | A string specifying the path on the filesystem to open the archive on. The path is permitted /// to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. |
return |
void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { this.BeginInvoke((MethodInvoker) delegate { DownloadProgress.Style = ProgressBarStyle.Marquee; string updatePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\"; using (ZipArchive archive = ZipFile.OpenRead(tempNameZip)) { int numFiles = archive.Entries.Count; int current = 1; DownloadProgress.Style = ProgressBarStyle.Blocks; foreach (ZipArchiveEntry entry in archive.Entries) { string fullName = entry.FullName; if (fullName.Substring(fullName.Length - 1) == "/") { string folderName = fullName.Remove(fullName.Length - 1); if (Directory.Exists(folderName)) { Directory.Delete(folderName, true); } Directory.CreateDirectory(folderName); } else { if (fullName != "GameLauncherUpdater.exe") { if (File.Exists(fullName)) { File.Delete(fullName); } Information.Text = "Extracting: " + fullName; try { entry.ExtractToFile(Path.Combine(updatePath, fullName)); } catch { } Delay.WaitMSeconds(200); } } DownloadProgress.Value = (int)((long)100 * current / numFiles); current++; } } Process.Start(@"GameLauncher.exe"); error("Update completed. Starting GameLauncher.exe"); }); }
private static void Extract45Framework(string zipFile, string extractPath) { ZipArchive zipArchive = DotNetZipFile.OpenRead(zipFile); if (zipArchive.Entries != null && zipArchive.Entries.Count > 0) { Console.WriteLine("Extracting..."); foreach (ZipArchiveEntry entry in zipArchive.Entries) { try { if (string.IsNullOrEmpty(entry.Name)) { // skip directory continue; } string file = Path.Combine(extractPath, entry.FullName); string path = Path.GetDirectoryName(file); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Console.WriteLine(" - '" + entry.FullName + "'..."); if (File.Exists(file)) { //Console.WriteLine(" - delete previous version..."); File.Delete(file); } entry.ExtractToFile(file); long length = (new FileInfo(file)).Length; if (entry.Length != length) { Console.WriteLine($" - Failed to extract! Extracted only {length} out of {entry.Length} bytes"); } } catch (Exception ex) { Console.WriteLine(" - Failed to extract: " + ex.Message); } } } }