1

In WPF, we can access the drives names using GetLogicalDrives() method in System.IO namespace. But for UWP, GetLogicalDrives() method is not in System.IO namespace. So how can I access drives names in windows 10?

Divakar
  • 514
  • 1
  • 9
  • 25
  • 1
    Possible duplicate of [List of all physical drives](http://stackoverflow.com/questions/36175414/list-of-all-physical-drives) – Romasz May 24 '16 at 04:38
  • That link does not have a answer for how to get drive info in Windows 10. If you know, please tell me – Divakar May 24 '16 at 06:01
  • The link says that you cannot do that - at least from what I know. – Romasz May 24 '16 at 06:02
  • When you need such PC specific info then maybe UWP is not the best platform. – H H May 24 '16 at 07:35

1 Answers1

1

Nor sure if this answers your question, but:

var removableDevices = KnownFolders.RemovableDevices;
var folders = await removableDevices.GetFoldersAsync();

This will return a collection you can iterate through:

foreach (StorageFolder folder in folders)
{
  sb.AppendFormat("DisplayName: {0}", folder.DisplayName);
}

So for a USB stick called "ESD-USB" this will return the name of the drive you see in Explorer along with the drive letter, e.g: "ESD-USB (D:)".

KnownFolders is in the Windows.Storage namespace.

Manifest: Update for question in comments

It's a while since I did any work on this, so not sure if this is all you need to do. Here's the relevant manifest info:

Under Capabilities I have the following ticked: Removable Storage, Pictures Library, Music Library, Videos Library, Internet (Client).

Adrian K
  • 9,880
  • 3
  • 33
  • 59
  • 1
    this gives an unathorize exception. Please elaborate on how to set up the manifest to get around this error. – Mike Sep 23 '17 at 15:22