Skip to content

Commit

Permalink
Prevent Windows Storage Sense from deleting extracted DLLs
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Oct 28, 2024
1 parent d546b33 commit fe5de36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/EventScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ private void HandleTimerEvent(bool updateLocation)
}

UpdateChecker.TryCheckAuto();
// Update access time for extracted DLL files to prevent Storage Sense from deleting them
string tempLibPath = Path.Combine(Path.GetTempPath(), ".net", Application.ProductName);
if (Directory.Exists(tempLibPath))
{
foreach (string filePath in Directory.EnumerateFiles(tempLibPath, "*.dll", SearchOption.AllDirectories))
{
File.SetLastAccessTime(filePath, DateTime.Now);
}
}
}

private void OnBackgroundTimerElapsed(object sender, EventArgs e)
Expand Down
7 changes: 3 additions & 4 deletions src/HiddenForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ protected override void WndProc(ref Message m)
m.Result = new IntPtr(1);
break;
case WM_ENDSESSION:
if (m.WParam != IntPtr.Zero)
if ((m.LParam & ENDSESSION_CLOSEAPP) != 0)
{
Application.Exit();
}
m.Result = IntPtr.Zero;
break;
default:
base.WndProc(ref m);
break;
}

base.WndProc(ref m);
}

private void HiddenForm_Load(object source, EventArgs e)
Expand Down

0 comments on commit fe5de36

Please sign in to comment.