File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -109,16 +109,19 @@ public async Task UpdatePropertiesAsync()
109
109
var properties = await Root . Properties . RetrievePropertiesAsync ( new [ ] { "System.FreeSpace" , "System.Capacity" } )
110
110
. AsTask ( ) . WithTimeoutAsync ( TimeSpan . FromSeconds ( 5 ) ) ;
111
111
112
- MaxSpace = ByteSize . FromBytes ( ( ulong ) properties [ "System.Capacity" ] ) ;
113
- FreeSpace = ByteSize . FromBytes ( ( ulong ) properties [ "System.FreeSpace" ] ) ;
114
- SpaceUsed = MaxSpace - FreeSpace ;
115
-
116
- SpaceText = string . Format (
117
- "DriveFreeSpaceAndCapacity" . GetLocalized ( ) ,
118
- FreeSpace . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ,
119
- MaxSpace . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ) ;
112
+ if ( properties [ "System.Capacity" ] != null && properties [ "System.FreeSpace" ] != null )
113
+ {
114
+ MaxSpace = ByteSize . FromBytes ( ( ulong ) properties [ "System.Capacity" ] ) ;
115
+ FreeSpace = ByteSize . FromBytes ( ( ulong ) properties [ "System.FreeSpace" ] ) ;
116
+ SpaceUsed = MaxSpace - FreeSpace ;
117
+
118
+ SpaceText = string . Format (
119
+ "DriveFreeSpaceAndCapacity" . GetLocalized ( ) ,
120
+ FreeSpace . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ,
121
+ MaxSpace . ToBinaryString ( ) . ConvertSizeAbbreviation ( ) ) ;
122
+ }
120
123
}
121
- catch ( NullReferenceException )
124
+ catch ( Exception )
122
125
{
123
126
SpaceText = "DriveCapacityUnknown" . GetLocalized ( ) ;
124
127
SpaceUsed = ByteSize . FromBytes ( 0 ) ;
You can’t perform that action at this time.
0 commit comments