@@ -48,6 +48,9 @@ private enum Privacy:int {
48
48
// number of automatic reconnection
49
49
private int reconnect = 0 ;
50
50
51
+ // local application data folder name
52
+ private string appdata = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) + "/Gmail Notifier" ;
53
+
51
54
// number of maximum automatic reconnection
52
55
private const int MAX_AUTO_RECONNECT = 3 ;
53
56
@@ -73,7 +76,7 @@ private void Main_Load(object sender, EventArgs e) {
73
76
Visible = false ;
74
77
75
78
// displays a systray notification on first load
76
- if ( Settings . Default . FirstLoad && ! Directory . EnumerateFiles ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) + "/Gmail Notifier" ) . Any ( ) ) {
79
+ if ( Settings . Default . FirstLoad && ! Directory . Exists ( appdata ) ) {
77
80
notifyIcon . ShowBalloonTip ( 7000 , translation . welcome , translation . firstLoad , ToolTipIcon . Info ) ;
78
81
79
82
// switchs the first load state
@@ -257,7 +260,7 @@ private async void AsyncAuthentication() {
257
260
} catch ( Exception ) {
258
261
259
262
// exits the application if the google api token file doesn't exists
260
- if ( ! Directory . EnumerateFiles ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) + "/Gmail Notifier" ) . Any ( ) ) {
263
+ if ( ! Directory . Exists ( appdata ) || ! Directory . EnumerateFiles ( appdata ) . Any ( ) ) {
261
264
MessageBox . Show ( translation . authenticationWithGmailRefused , translation . authenticationFailed , MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
262
265
Application . Exit ( ) ;
263
266
}
@@ -283,7 +286,7 @@ private async Task<UserCredential> AsyncAuthorizationBroker() {
283
286
new string [ ] { GmailService . Scope . GmailModify } ,
284
287
"user" ,
285
288
CancellationToken . None ,
286
- new FileDataStore ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) + "/Gmail Notifier" , true )
289
+ new FileDataStore ( appdata , true )
287
290
) ;
288
291
}
289
292
}
@@ -726,7 +729,9 @@ private void buttonGmailDisconnect_Click(object sender, EventArgs e) {
726
729
}
727
730
728
731
// deletes the local application data folder and the client token file
729
- Directory . Delete ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) + "/Gmail Notifier" , true ) ;
732
+ if ( Directory . Exists ( appdata ) ) {
733
+ Directory . Delete ( appdata , true ) ;
734
+ }
730
735
731
736
// restarts the application
732
737
this . restart ( ) ;
0 commit comments