mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
clearing temp folder when the app closes
This commit is contained in:
parent
ccff5b822a
commit
7fd36718f5
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
@ -47,6 +48,31 @@ namespace Wabbajack
|
||||
{
|
||||
_logger.LogInformation("Beginning shutdown...");
|
||||
_mwvm.CancelRunningTasks(TimeSpan.FromSeconds(10));
|
||||
|
||||
// Cleaning the temp folder when the app closes since it can take up multiple Gigabytes of Storage
|
||||
var tempDirectory = Environment.CurrentDirectory + "\\temp";
|
||||
_logger.LogInformation("Clearing {TempDir}",tempDirectory);
|
||||
try
|
||||
{
|
||||
var directoryInfo = new DirectoryInfo(tempDirectory);
|
||||
|
||||
foreach (var file in directoryInfo.EnumerateFiles())
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
foreach (var dir in directoryInfo.EnumerateDirectories())
|
||||
{
|
||||
dir.Delete(true);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Finished clearing {TempDir}",tempDirectory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug("Directory {TempDir} doesn't exist",tempDirectory);
|
||||
}
|
||||
|
||||
|
||||
Application.Current.Shutdown();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user