Windows Phone 8 新增功能:对SD卡的访问

 

Windows Phone 8 新增加了对 SD 卡的支持,开发者可以直接访问SD卡非加密的内容,但无法执行Write操作

而且用户可以将已通过审核的应用拷贝到SD上进行安装,只是在安装的过程中需要用户手机联网到marketplace上进行验证,如果是合法程序则可以直接安装使用。

代码中对SD卡操作需要添加 ID_CAP_REMOVABLE_STORAGE 能力,

使用代码片段,引用自官方Route mapper sample例子,完整例子请移步到:点击打开链接

 

        // Process a route from the SD card.
        private async Task ProcessSDGPXFile(string _sdFilePath)
        {
            // Connect to the current SD card.
            ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, get the route from the SD card.
            if (sdCard != null)
            {
                try
                {
                    // Get the route (.GPX file) from the SD card.
                    ExternalStorageFile file = await sdCard.GetFileAsync(_sdFilePath);

                    // Create a stream for the route.
                    Stream s = await file.OpenForReadAsync();

                    // Read the route data.
                    ReadGPXFile(s);
                }
                catch (FileNotFoundException)
                {
                    // The route is not present on the SD card.
                    MessageBox.Show("That route is missing on your SD card.");
                }
            }
            else
            {
                // No SD card is present.
                MessageBox.Show("The SD card is mssing. Insert an SD card that has a Routes folder containing at least one .GPX file and try again.");
            }
        }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值