Skip to content

Commit 3b96cb2

Browse files
authored
Fixed an issue that would occur when a drive is connected/disconnected (#2257)
1 parent 3ffa220 commit 3b96cb2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Files/Filesystem/DriveItem.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using Files.Helpers;
44
using Microsoft.Toolkit.Mvvm.ComponentModel;
55
using Microsoft.Toolkit.Uwp.Extensions;
6+
using Microsoft.Toolkit.Uwp.Helpers;
67
using System;
78
using System.Linq;
89
using System.Threading;
910
using System.Threading.Tasks;
11+
using Windows.ApplicationModel.Core;
1012
using Windows.Storage;
1113
using Windows.UI.Xaml;
1214

@@ -54,10 +56,11 @@ public DriveItem(StorageFolder root, DriveType type)
5456
Type = type;
5557
Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path;
5658
Root = root;
57-
GetDriveItemProperties();
59+
60+
CoreApplication.MainView.ExecuteOnUIThreadAsync(() => GetDriveItemProperties());
5861
}
5962

60-
private async void GetDriveItemProperties()
63+
private async Task GetDriveItemProperties()
6164
{
6265
try
6366
{
@@ -66,8 +69,8 @@ private async void GetDriveItemProperties()
6669

6770
MaxSpace = ByteSize.FromBytes((ulong)properties["System.Capacity"]);
6871
FreeSpace = ByteSize.FromBytes((ulong)properties["System.FreeSpace"]);
69-
7072
SpaceUsed = MaxSpace - FreeSpace;
73+
7174
SpaceText = string.Format(
7275
"DriveFreeSpaceAndCapacity".GetLocalized(),
7376
FreeSpace.ToBinaryString().ConvertSizeAbbreviation(),

0 commit comments

Comments
 (0)