Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
自动更新时只清理exe,dll,config
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Nov 30, 2017
1 parent 7c78bd0 commit b148efd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
7 changes: 0 additions & 7 deletions AdmiralRoom/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ protected override void OnStartup(StartupEventArgs e)
if (file.Name.EndsWith(".xml.old"))
file.MoveTo(file.FullName.Replace(".old", ""));
else file.Delete();
foreach (var folder in rootfolder.GetDirectories())
if (!Updater.Updater.ProtectedFolders.Contains(folder.Name.ToLowerInvariant()))
try
{
folder.Delete();
}
catch { }

Win32Helper.SetIEEmulation(11001);
Win32Helper.SetGPURendering(true);
Expand Down
12 changes: 4 additions & 8 deletions AdmiralRoom/Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ private Updater()
}
public Timer Timer { get; } = new Timer(3600 * 12 * 1000);
public static Updater Instance { get; } = new Updater();
public static readonly string[] ProtectedFolders = { "logs", "information", "modules", "sound" };
private Uri updateurl;
private string downloadfilename;

Expand Down Expand Up @@ -208,13 +207,10 @@ public Task UpdateFileAsync() => Task.Factory.StartNew(() =>
{
Environment.CurrentDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var rootfolder = new DirectoryInfo(".");
foreach (var file in rootfolder.GetFiles())
if (!file.Name.EndsWith(".xml") && file.Name != downloadfilename)
file.MoveTo(file.FullName + ".old");
foreach (var folder in rootfolder.GetDirectories())
if (!ProtectedFolders.Contains(folder.Name.ToLowerInvariant()))
foreach (var file in folder.GetFiles())
file.MoveTo(file.FullName + ".old");
foreach (var file in rootfolder.GetFiles("*.exe", SearchOption.AllDirectories)
.Concat(rootfolder.GetFiles("*.dll", SearchOption.AllDirectories))
.Concat(rootfolder.GetFiles("*.config", SearchOption.AllDirectories)))
file.MoveTo(file.FullName + ".old");
using (var zip = ZipFile.OpenRead(downloadfilename))
foreach (var entry in zip.Entries)
{
Expand Down

0 comments on commit b148efd

Please sign in to comment.