How to know one StorageFolder-obj belongs to SD or Phone?

后端 未结 1 1821
死守一世寂寞
死守一世寂寞 2021-01-21 08:08

Is there have way to know a StorageFolder-obj belongs to SD or Phone on WP8.1? Thanks you.

相关标签:
1条回答
  • 2021-01-21 08:38

    You can do it for example by checking the Path of StorageFolder (or StorageFIle):

    string folderPath = yourStorageFolder.Path;
    if (folderPath.StartsWith("C:")) // on Phone
    else // on SD Card
    
    • if it begins with D: (or other letter - not C:) - it means it belongs to SD card,
    • if it begins with C: - it exists on Phone,

    EDIT - as Adam has said in comments - it may be more suitable to check first if file is on the Phone, in case the System had assigned other letter than D: for SD card.

    0 讨论(0)
提交回复
热议问题