Skip to content

Commit

Permalink
Fonction supprimer générique
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreOlivierBrillant committed Oct 16, 2024
1 parent c423b4b commit 5ba16ec
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions scriptsharp/ScriptSharp/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

Expand Down Expand Up @@ -373,13 +374,9 @@ public static void DeleteAll()
DeleteThis( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "Local", "Android"));
DeleteThis( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "Local", "Google", "AndroidStudio2024.2"));
"AppData", "Local", "Google", "AndroidStudio*"));
DeleteThis( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "Roaming", "Google", "AndroidStudio2024.2"));
DeleteThis( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "Local", "Google", "AndroidStudio2024.1"));
DeleteThis( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "Roaming", "Google", "AndroidStudio2024.1"));
"AppData", "Roaming", "Google", "AndroidStudio*"));
DeleteThis(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
DeleteThis(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".android"));
DeleteThis(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".gradle"));
Expand All @@ -389,12 +386,24 @@ public static void DeleteAll()

private static void DeleteThis(string path)
{
try {
if (Directory.Exists(path))
{ Directory.Delete(path, true); }
try
{
DirectoryInfo parent = Directory.GetParent(path)!;
string pattern = new DirectoryInfo(path).Name;
foreach (string dir in Directory.GetDirectories(parent.FullName, pattern))
{
Directory.Delete(dir);
}

foreach (string file in Directory.GetFiles(parent.FullName, pattern))
{
File.Delete(file);
}
}
catch (Exception ex)
{ Console.WriteLine($"An error occurred while deleting the directory {path}: {ex.Message} {ex.Data}"); }
{
Console.WriteLine($"An error occurred while deleting the directory {path}: {ex.Message} {ex.Data}");
}
}
}

0 comments on commit 5ba16ec

Please sign in to comment.