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