Skip to content

Instantly share code, notes, and snippets.

@azyobuzin
Created October 27, 2011 08:46
Show Gist options
  • Save azyobuzin/1319082 to your computer and use it in GitHub Desktop.
Save azyobuzin/1319082 to your computer and use it in GitHub Desktop.
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