2017-11-08 7 views
2
var myDevices= await Windows.Devices. 
    Enumeration.DeviceInformation. 
    FindAllAsync(Windows.Devices.Enumeration.DeviceClass.PortableStorageDevice); 

foreach(var x in myDevices) 
{ 
    string s = string.Format("Kind:{0} Name:{1} Id:{2})", 
     x.Kind.tostring(), x.Name, x.Id); 
    listbox1.items.add(s); 
} 

이것은 내 예제 코드입니다. myDevices 객체 항목의 드라이브에 액세스 할 수있는 속성을 검색 할 수 있습니까? (D : \ 또는 E : \ etc와 같은 것). 심지어 나는 어쩌면 그것은 당신의 경우에 여전히 적용,UWP 범용 응용 프로그램에서 드라이브 문자 사용

+0

@VMAtm 당신이 [RemovableDevices]의 하위 폴더의 경로 속성을 사용하여 같은 드라이브 이름을 얻을 수있는 지적 (https : //로 docs.microsoft.com/en-us/uwp/api/windows.storage.knownfolders#Windows_Storage_KnownFolders_RemovableDevices). –

답변

2

는 윈도우 8에 대한 this 기사 발견 (rasperry PI3에 IOT를이 의미가 있지만, 플랫폼의 경우 잘 모릅니다) 창 IOT 대시 보드 의 드라이브 문자를 볼 수 있습니까?

  • KnownFolders.RemovableDevices 각 장치에 당신 '의 경로를 Windows.Devices.Portable.StorageDevice.FromId(device.Id);를 통해
  • StorageDevice 및 DeviceInformation를 결정하기 위해 사용할 수있는 각 장치에 대한 StorageFolder 객체로 : 기본적으로는 두 가지 방법으로 폴더와 같은 장치를 얻을 수 있다고 말한다 MSDN에 myDevices

Access the SD card 문서에서 발견했습니다 또한 경로에 대한 정보를 얻을 수있는 방법으로 StorageFolder 클래스를 언급하고있다.

사이드 참고 : 문자열이 건설 완화 문자열 보간을 사용할 수 있습니다

string s = $"Kind:{x.Kind} Name:{x.Name} Id:{x.Id})";