Skip to content

Commit fe5de36

Browse files
committed
Prevent Windows Storage Sense from deleting extracted DLLs
1 parent d546b33 commit fe5de36

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/EventScheduler.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ private void HandleTimerEvent(bool updateLocation)
238238
}
239239

240240
UpdateChecker.TryCheckAuto();
241+
// Update access time for extracted DLL files to prevent Storage Sense from deleting them
242+
string tempLibPath = Path.Combine(Path.GetTempPath(), ".net", Application.ProductName);
243+
if (Directory.Exists(tempLibPath))
244+
{
245+
foreach (string filePath in Directory.EnumerateFiles(tempLibPath, "*.dll", SearchOption.AllDirectories))
246+
{
247+
File.SetLastAccessTime(filePath, DateTime.Now);
248+
}
249+
}
241250
}
242251

243252
private void OnBackgroundTimerElapsed(object sender, EventArgs e)

src/HiddenForm.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ protected override void WndProc(ref Message m)
5353
m.Result = new IntPtr(1);
5454
break;
5555
case WM_ENDSESSION:
56-
if (m.WParam != IntPtr.Zero)
56+
if ((m.LParam & ENDSESSION_CLOSEAPP) != 0)
5757
{
5858
Application.Exit();
5959
}
6060
m.Result = IntPtr.Zero;
6161
break;
62-
default:
63-
base.WndProc(ref m);
64-
break;
6562
}
63+
64+
base.WndProc(ref m);
6665
}
6766

6867
private void HiddenForm_Load(object source, EventArgs e)

0 commit comments

Comments
 (0)