Repository navigation
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
67 lines (56 loc) · 1.94 KB
/
Copy pathApp.xaml.cs
File metadata and controls
67 lines (56 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.Maui.Controls;
using Microsoft.Maui.Storage;
using StuAuthMobile.Classe;
using StuAuthMobile.Page;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Threading;
namespace StuAuthMobile
{
public partial class App : Application
{
public App()
{
InitializeComponent();
string savedLang = Preferences.Get("LangCode", "en");
var loc = (Loc)Application.Current.Resources["Loc"];
loc.Culture = new CultureInfo(savedLang);
MainPage = new AppShell();
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
var ex = e.ExceptionObject as Exception;
Debug.WriteLine($"Crash : {ex?.Message}");
CleanupBeforeExit();
};
}
public static void CleanupBeforeExit()
{
Debug.WriteLine($"etat du bool: {HttpServer.isStart}");
if (HttpServer.isStart)
{
Debug.WriteLine("l'application ne se ferme pas");
return;
}
try
{
string appDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StuAuthData");
string filePath = Path.Combine(appDirectory, "Account_decrypted.dat");
string filePath2 = Path.Combine(appDirectory, "Account.dat");
if (File.Exists(filePath))
{
File.Delete(filePath);
}
long fileSize = new FileInfo(filePath2).Length;
if (fileSize == 0 && File.Exists(filePath2))
{
File.Delete(filePath2);
}
}
catch (Exception ex)
{
Debug.WriteLine($"Erreur lors de la suppression des fichiers : {ex.Message}");
}
}
}
}