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."); } }