Hololens文件讀寫


unity 內勾選 RemovableStorage 選項或 Package.appxmanifest 勾選 可移動存儲 選項

uwp app IO操作用 StreamReader 會提示沒有權限,如:

 1 using UnityEngine;  2 using System.IO;  3 public class test : MonoBehaviour  4 {  5 
 6     void Start ()  7  {  8         string path = Path.Combine(Application.streamingAssetsPath, "test.txt");  9         StreamReader s = new StreamReader(path); 10         string end = s.ReadToEnd(); 11  Debug.Log(end); 12  } 13 
14 }

 

結果會報錯,uwp應用的IO操作需要用到 StorageFile 類(導出uwp工程后添加 Windows.Storage 命名空間才能夠使用StorageFile類),或者使用 File 類的靜態方法,www 讀取還沒嘗試過

 

 

參考資料:win10 UWP讀寫文件   

                 win10 uwp 讀取文本GBK錯誤

                 Hololens開發初探踩的一些坑

                   


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM