Grazie alla classe DeviceInformation, di Windows.Devices.Enumeration, possiamo conoscere i dispositivi collegati al device su cui è in esecuzione la nostra app. La classe espone il metodo FindAllAsync che accetta come parametro una stringa che rappresenta il tipo di device da cercare.
Nella fattispecie, se vogliamo conoscere le informazioni sugli storage portatili collegati possiamo usare il metodo GetDeviceSelector di Windows.Devices.Portable.StorageDevice, come nell'esempio.
var str = new StringBuilder(); var devices = await DeviceInformation.FindAllAsync(Windows.Devices.Portable.StorageDevice.GetDeviceSelector()); foreach (var device in devices) { str.AppendFormat("Id {0}{1}", device.Id, Environment.NewLine); str.AppendFormat("Name {0}{1}", device.Name, Environment.NewLine); str.AppendFormat("IsDefault {0}{1}", device.IsDefault, Environment.NewLine); str.AppendFormat("IsEnabled {0}{1}", device.IsEnabled, Environment.NewLine); if (device.EnclosureLocation != null) str.AppendFormat("{0}{1}", device.EnclosureLocation.Panel, Environment.NewLine); foreach (var prop in device.Properties) { str.AppendFormat(" Propertiey Key {0} Value {1} {2}", prop.Key, prop.Value, Environment.NewLine); } var thumb = await device.GetThumbnailAsync(); var bmpi = new BitmapImage(); await bmpi.SetSourceAsync(thumb); img1.Source = bmpi;
Dello storage collegato possiamo avere molte informazioni tra cui anche la thumbnail che gli assegna il sistema operativo.

Commenti
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Approfondimenti
Rendere i propri workflow e le GitHub Action utilizzate più sicure
Eliminare record doppi in Sql Server
Creare una libreria CSS universale: i bottoni
Collegare applicazioni server e client con .NET Aspire
Utilizzare DeepSeek R1 con Azure AI
Integrare modelli AI in un workflow di GitHub
Utilizzare Locust con Azure Load Testing
Gestire progetti NPM in .NET Aspire
Integrazione di Copilot in .NET Aspire
Aggiornare a .NET 9 su Azure App Service
Usare i settings di serializzazione/deserializzazione di System.Text.Json di ASP.NET all'interno di un'applicazione non web
Gestione delle scrollbar dinamiche in HTML e CSS