mirror of
https://gitlab.com/cleanflash/installer.git
synced 2026-08-12 18:31:37 +08:00
uninstall: Less aggressive directory deletion
This commit is contained in:
@@ -21,12 +21,12 @@ namespace CleanFlashCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void RecursiveDelete(DirectoryInfo rootDir, DirectoryInfo baseDir, string filename) {
|
public static void RecursiveDelete(DirectoryInfo rootDir, DirectoryInfo baseDir, string filename) {
|
||||||
if (!baseDir.Exists) {
|
if (!baseDir.FullName.StartsWith(rootDir.FullName)) {
|
||||||
|
// Sanity check.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!baseDir.FullName.StartsWith(rootDir.FullName)) {
|
if (!baseDir.Exists) {
|
||||||
// Sanity check.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,15 +44,6 @@ namespace CleanFlashCommon {
|
|||||||
DeleteFile(file);
|
DeleteFile(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.EnumerateFileSystemEntries(baseDir.FullName).Any()) {
|
|
||||||
try {
|
|
||||||
baseDir.Delete();
|
|
||||||
} catch {
|
|
||||||
HandleUtil.KillProcessesUsingFile(baseDir.FullName);
|
|
||||||
baseDir.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteFile(FileInfo file) {
|
public static void DeleteFile(FileInfo file) {
|
||||||
@@ -77,6 +68,7 @@ namespace CleanFlashCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HandleUtil.KillProcessesUsingFile(file.FullName);
|
HandleUtil.KillProcessesUsingFile(file.FullName);
|
||||||
|
Thread.Sleep(500);
|
||||||
file.Delete();
|
file.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,6 +87,31 @@ namespace CleanFlashCommon {
|
|||||||
RecursiveDelete(dirInfo, dirInfo, null);
|
RecursiveDelete(dirInfo, dirInfo, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void WipeFolder(string baseDir) {
|
||||||
|
DirectoryInfo dirInfo = new DirectoryInfo(baseDir);
|
||||||
|
|
||||||
|
if (!dirInfo.Exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RecursiveDelete(dirInfo);
|
||||||
|
|
||||||
|
if (!Directory.EnumerateFileSystemEntries(dirInfo.FullName).Any()) {
|
||||||
|
try {
|
||||||
|
dirInfo.Delete();
|
||||||
|
} catch {
|
||||||
|
HandleUtil.KillProcessesUsingFile(dirInfo.FullName);
|
||||||
|
Thread.Sleep(500);
|
||||||
|
|
||||||
|
try {
|
||||||
|
dirInfo.Delete();
|
||||||
|
} catch {
|
||||||
|
// We've tried for long enough...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void DeleteFile(string file) {
|
public static void DeleteFile(string file) {
|
||||||
DeleteFile(new FileInfo(file));
|
DeleteFile(new FileInfo(file));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,22 +68,22 @@ namespace CleanFlashCommon {
|
|||||||
|
|
||||||
public static void DeleteFlashCenter() {
|
public static void DeleteFlashCenter() {
|
||||||
// Remove Flash Center from Program Files
|
// Remove Flash Center from Program Files
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "FlashCenter"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "FlashCenter"));
|
||||||
|
|
||||||
if (Environment.Is64BitOperatingSystem) {
|
if (Environment.Is64BitOperatingSystem) {
|
||||||
// Remove Flash Center from Program Files (x86)
|
// Remove Flash Center from Program Files (x86)
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "FlashCenter"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "FlashCenter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove start menu shortcuts
|
// Remove start menu shortcuts
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Flash Center"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Flash Center"));
|
||||||
|
|
||||||
// Remove Flash Center cache and user data
|
// Remove Flash Center cache and user data
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Flash_Center"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Flash_Center"));
|
||||||
|
|
||||||
// Remove shared start menu shortcuts
|
// Remove shared start menu shortcuts
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "Flash Center"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "Flash Center"));
|
||||||
FileUtil.RecursiveDelete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", "Flash Center"));
|
FileUtil.WipeFolder(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", "Flash Center"));
|
||||||
FileUtil.DeleteFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Flash Player.lnk"));
|
FileUtil.DeleteFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Flash Player.lnk"));
|
||||||
|
|
||||||
// Remove Desktop shortcut
|
// Remove Desktop shortcut
|
||||||
@@ -97,7 +97,7 @@ namespace CleanFlashCommon {
|
|||||||
string parentName = Path.GetFileName(dir);
|
string parentName = Path.GetFileName(dir);
|
||||||
|
|
||||||
if (parentName.Length == 11 && parentName.EndsWith(".tmp")) {
|
if (parentName.Length == 11 && parentName.EndsWith(".tmp")) {
|
||||||
FileUtil.RecursiveDelete(dir);
|
FileUtil.WipeFolder(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user