本文介绍了如何知道一个 StorageFolder-obj 属于 SD 还是 Phone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法知道 WP8.1 上的 StorageFolder-obj 属于 SD 还是 Phone?谢谢你.

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

推荐答案

例如,您可以通过查看 StorageFolder(或StorageFIle)的路径:

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

  • 如果它以 D:(或其他字母 - 不是 C:)开头 - 表示它属于 SD 卡,
  • 如果它以 C: 开头 - 它存在于电话上,
    • 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,
    • 编辑 - 正如亚当在评论中所说 - 可能更适合先检查文件是否在电话上,以防系统为 SD 卡分配了 D: 以外的其他字母.

      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.

      这篇关于如何知道一个 StorageFolder-obj 属于 SD 还是 Phone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 16:48