讀取U盤的檔案時:
StorageFile file = await folder.GetFileAsync("myfile.txt");
抛出異常System.UnauthorizedAccessException: 拒絕通路。
解決方案:
打開項目中的應用部件清單檔案 (Package.appxmanifest)
1.在“功能”頁籤中勾選"可移動存儲"。
2.在“聲明”頁籤中。
從下拉清單中選擇“檔案類型關聯”,然後單擊“添加”。
輸入 txt<code></code> 作為“名稱”。
輸入 <code>.txt</code> 作為“檔案類型”。
輸入“images\Icon.png”作為“徽标”。
按 Ctrl+S 儲存對 package.appxmanifest 的更改。
重新運作即可。
代碼: