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读写文件