title: UnauthorizedAccessException: Access to the path is denies Ios
body: <p>I know this has come up some time but I am not able to solve the error with any of the solutions I tried.</p>
  
  <p>I just started testing my application - to save a screenshot to ios device Code is - </p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>To wite the file </p>
  
  <pre><code>    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 --&gt;" + Application.dataPath);
          //string savepath = Application.dataPath.Replace ("game.app/Data", "/Documents/");
          System.IO.File.WriteAllBytes (System.IO.Path.Combine(Path , fileName), screenshot);
  </code></pre>
  
  <p>Assuming screenshot is bytes[]</p>
  
  <p>I get the exception that as in subject. I am using Unity.</p>
  
  <p>Error that I get is - </p>
  
  <blockquote>
    <p>UnauthorizedAccessException: Access to the path
    "/var/containers/Bundle/Application/9DA2D489-2037-451E-87D1-FA7354ECD0D1/Documents"
    is denied.</p>
  </blockquote>