-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathProgram.cs
More file actions
24 lines (22 loc) · 1.09 KB
/
Copy pathProgram.cs
File metadata and controls
24 lines (22 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace EasySystemCleaner;
internal static class Program
{
[STAThread]
static void Main(string[] args)
{
ApplicationConfiguration.Initialize();
var engine = new CleanerEngine(AppContext.BaseDirectory);
if (args.Any(a => a.Equals("/AUTO", StringComparison.OrdinalIgnoreCase)))
{
var result = engine.Clean(engine.LoadSelection());
engine.AppendLog($"Automatic cleanup: {result.DeletedFiles} files, {Formatter.Bytes(result.FreedBytes)} freed.");
if (result.Errors.Count == 0 && args.Any(a => a.Equals("/SHUTDOWN", StringComparison.OrdinalIgnoreCase))) System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("shutdown", "/s /t 15") { UseShellExecute = false });
return;
}
Application.Run(new MainForm(engine));
}
}
internal static class Formatter
{
public static string Bytes(long bytes) => bytes switch { < 1024 => $"{bytes} B", < 1024 * 1024 => $"{bytes / 1024d:F1} KB", < 1024L * 1024 * 1024 => $"{bytes / 1024d / 1024:F1} MB", _ => $"{bytes / 1024d / 1024 / 1024:F2} GB" };
}