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

来源:互联网 发布:在线aes算法 编辑:程序博客网 时间:2024/04/25 04:23
[csharp] view plaincopy
  1.    

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

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

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

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

 

[csharp] view plaincopy
  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. }  


http://blog.csdn.net/flashtao613/article/details/8135867
原创粉丝点击