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

[csharp]  view plain copy
  1.    

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

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

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

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

 

[csharp]  view plain copy
  1. // Process a route from the SD card.  
  2. private async Task ProcessSDGPXFile(string _sdFilePath)  
  3. {  
  4.     // Connect to the current SD card.  
  5.     ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();  
  6.   
  7.     // If the SD card is present, get the route from the SD card.  
  8.     if (sdCard != null)  
  9.     {  
  10.         try  
  11.         {  
  12.             // Get the route (.GPX file) from the SD card.  
  13.             ExternalStorageFile file = await sdCard.GetFileAsync(_sdFilePath);  
  14.   
  15.             // Create a stream for the route.  
  16.             Stream s = await file.OpenForReadAsync();  
  17.   
  18.             // Read the route data.  
  19.             ReadGPXFile(s);  
  20.         }  
  21.         catch (FileNotFoundException)  
  22.         {  
  23.             // The route is not present on the SD card.  
  24.             MessageBox.Show("That route is missing on your SD card.");  
  25.         }  
  26.     }  
  27.     else  
  28.     {  
  29.         // No SD card is present.  
  30.         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.");  
  31.     }  
  32. }  


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值