【发布时间】:2017-07-16 15:40:51
【问题描述】:
我知道这已经出现了一段时间,但我无法使用我尝试的任何解决方案来解决该错误。
我刚开始测试我的应用程序-将屏幕截图保存到ios设备代码是-
string GetiPhoneDocumentsPath()
{
string path = Application.dataPath.Substring(0, Application.dataPath.Length - 5);
path = path.Substring(0, path.LastIndexOf("/"));
return path + "/Documents/";
}
string CreateImagesDirectory(string documentsPath) {
//System.IO.File.SetAttributes (documentsPath, FileAttributes.Normal);
string imagePath = documentsPath +"magicimages/";
if (Directory.Exists(imagePath)) {return imagePath;}
DirectoryInfo t = new DirectoryInfo(documentsPath);
//Directory.CreateDirectory(imagePath);
t.CreateSubdirectory("magicimages");
System.IO.File.SetAttributes (imagePath, FileAttributes.Normal);
return imagePath;
}
写入文件
Debug.Log("Do nothing actually as we need to save to persistent data path");
string documentsPathIphone = GetiPhoneDocumentsPath();
Debug.Log ("document path" + documentsPathIphone);
string imagePath = CreateImagesDirectory (documentsPathIphone);
//Path = imagePath + fileName;
Debug.Log ("path iphone" + Path);
Debug.Log("Appllicarion data path -->" + Application.dataPath);
//string savepath = Application.dataPath.Replace ("game.app/Data", "/Documents/");
System.IO.File.WriteAllBytes (System.IO.Path.Combine(Path , fileName), screenshot);
假设截图是字节[]
我得到了主题中的异常。我正在使用 Unity。
我得到的错误是 -
UnauthorizedAccessException: 访问路径 “/var/containers/Bundle/Application/9DA2D489-2037-451E-87D1-FA7354ECD0D1/Documents” 被拒绝。
【问题讨论】:
标签: ios unity3d vuforia access-denied