Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 864223a

Browse files
Add error message if Updater fails to delete old YAMDCC installation
1 parent 3947095 commit 864223a

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

YAMDCC.ECInspector/ec.ico

-47.5 KB
Binary file not shown.

YAMDCC.Updater/Program.cs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,35 @@ private static void InstallUpdate(
128128

129129
// delete the old YAMDCC installation
130130
dlg.Caption = "Installing YAMDCC update...";
131-
DirectoryInfo di = new(destPath);
132-
foreach (FileInfo fi in di.GetFiles())
131+
DirectoryInfo di;
132+
try
133133
{
134-
fi.Delete();
135-
}
136-
foreach (DirectoryInfo dir in di.GetDirectories())
137-
{
138-
if (dir.FullName != confPath &&
139-
dir.FullName != oldPath &&
140-
dir.FullName != updatePath)
134+
di = new(destPath);
135+
foreach (FileInfo fi in di.GetFiles())
136+
{
137+
fi.Delete();
138+
}
139+
foreach (DirectoryInfo dir in di.GetDirectories())
141140
{
142-
dir.Delete(true);
141+
if (dir.FullName != confPath &&
142+
dir.FullName != oldPath &&
143+
dir.FullName != updatePath)
144+
{
145+
dir.Delete(true);
146+
}
143147
}
144148
}
149+
catch (UnauthorizedAccessException ex)
150+
{
151+
Utils.ShowError(
152+
"Failed to delete old YAMDCC installation.\n" +
153+
"This probably means something else has YAMDCC's files open.\n" +
154+
"See issue #62 on the YAMDCC GitHub for more info.\n\n" +
155+
"Details:\n" +
156+
$"{ex.GetType()}: {ex.Message}\n" +
157+
$"{ex.StackTrace}");
158+
return false;
159+
}
145160

146161
// move updated YAMDCC into place
147162
di = new(updatePath);

0 commit comments

Comments
 (0)