A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.1 KiB

using System;
using System.Collections.ObjectModel;
using System.IO;
using Avalonia.Controls.Platform;
using Avalonia.Reactive;
namespace Avalonia.Dialogs.Internal;
internal class BclMountedVolumeInfoProvider : IMountedVolumeInfoProvider
{
public IDisposable Listen(ObservableCollection<MountedVolumeInfo> mountedDrives)
{
foreach (var drive in DriveInfo.GetDrives())
{
string directory;
ulong totalSize;
try
{
if (!drive.IsReady)
continue;
totalSize = (ulong)drive.TotalSize;
directory = drive.RootDirectory.FullName;
_ = new DirectoryInfo(directory).EnumerateFileSystemInfos();
}
catch
{
continue;
}
mountedDrives.Add(new MountedVolumeInfo
{
VolumeLabel = string.IsNullOrEmpty(drive.VolumeLabel.Trim()) ? directory : drive.VolumeLabel,
VolumePath = directory,
VolumeSizeBytes = totalSize
});
}
return Disposable.Empty;
}
}