@@ -42,8 +42,25 @@ public UsageTracker(
42
42
[ Import ( typeof ( SVsServiceProvider ) ) ] IServiceProvider serviceProvider )
43
43
{
44
44
fileExists = ( path ) => System . IO . File . Exists ( path ) ;
45
- readAllText = ( path , encoding ) => System . IO . File . ReadAllText ( path , encoding ) ;
46
- writeAllText = ( path , content , encoding ) => System . IO . File . WriteAllText ( path , content , encoding ) ;
45
+ readAllText = ( path , encoding ) =>
46
+ {
47
+ try
48
+ {
49
+ return System . IO . File . ReadAllText ( path , encoding ) ;
50
+ }
51
+ catch
52
+ {
53
+ return null ;
54
+ }
55
+ } ;
56
+ writeAllText = ( path , content , encoding ) =>
57
+ {
58
+ try
59
+ {
60
+ System . IO . File . WriteAllText ( path , content , encoding ) ;
61
+ }
62
+ catch { }
63
+ } ;
47
64
dirCreate = ( path ) => System . IO . Directory . CreateDirectory ( path ) ;
48
65
49
66
this . connectionManager = connectionManager ;
@@ -138,9 +155,18 @@ public void IncrementLoginCount()
138
155
139
156
UsageStore LoadUsage ( )
140
157
{
141
- var result = fileExists ( storePath ) ?
142
- SimpleJson . DeserializeObject < UsageStore > ( readAllText ( storePath , Encoding . UTF8 ) ) :
143
- new UsageStore { Model = new UsageModel ( ) } ;
158
+ var json = fileExists ( storePath ) ? readAllText ( storePath , Encoding . UTF8 ) : null ;
159
+ UsageStore result = null ;
160
+ try
161
+ {
162
+ result = json != null ?
163
+ SimpleJson . DeserializeObject < UsageStore > ( json ) :
164
+ new UsageStore { Model = new UsageModel ( ) } ;
165
+ }
166
+ catch
167
+ {
168
+ result = new UsageStore { Model = new UsageModel ( ) } ;
169
+ }
144
170
145
171
result . Model . Lang = CultureInfo . InstalledUICulture . IetfLanguageTag ;
146
172
result . Model . AppVersion = AssemblyVersionInformation . Version ;
0 commit comments