Created
October 27, 2011 08:46
-
-
Save azyobuzin/1319082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.Net; | |
using Azyobuzi.Azyotter.Util; | |
using Ionic.Zip; | |
namespace Azyobuzi.Azyotter.Updater | |
{ | |
public static class UpdateCore | |
{ | |
public static string Download(Update update) | |
{ | |
var tmpFile = Path.GetTempFileName(); | |
using (var wc = new WebClient()) | |
{ | |
wc.Headers.Add(HttpRequestHeader.UserAgent, "Azyotter.Updater v" + AssemblyUtil.GetInformationalVersion()); | |
wc.DownloadFile(update.Uri, tmpFile); | |
} | |
return tmpFile; | |
} | |
public static void Apply(string zipFile, string targetDir) | |
{ | |
using (var zip = ZipFile.Read(zipFile)) | |
{ | |
zip.ExtractAll(targetDir, ExtractExistingFileAction.OverwriteSilently); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment