【问题标题】:Xamarin iOS 8 Bundle Resource - Access to the path is deniedXamarin iOS 8 Bundle Resource - 访问路径被拒绝
【发布时间】:2014-11-17 21:39:29
【问题描述】:

我有一个 Xamarin iOS 项目,其中包含一个已标记为捆绑资源的文件。该文件在项目中配置如下:

<BundleResource Include="my\folder\file.xyz" />

我一直在使用以下方法以流的形式访问文件:

string ext = Path.GetExtension ("file.xyz");
string filenameNoExt = filename.Substring (0, filename.Length - ext.Length);
string path = Path.Combine ("my/folder", filenameNoExt);
var resourcePathname = NSBundle.MainBundle.PathForResource (path, ext.Substring (1, ext.Length - 1));
var fStream = new FileStream (resourcePathname, FileMode.Open);

它不适用于 iOS 8。它在 iOS 8 之前可以正常工作。

我收到以下错误:

Access to the path "/private/var/mobile/Containers/Bundle/Application/0E6DD32F-4E6F-4E54-B47E-A91060097E16/myapp.app/my/folder/file.xyz" is denied.

确切地说,我需要进行哪些更改才能使其在 iOS 8 中运行?

【问题讨论】:

    标签: xamarin.ios xamarin


    【解决方案1】:

    在创建流时还要提供FileAccess.Read。否则它将为只读文件抛出UnauthorizedAccessException

    【讨论】:

      猜你喜欢
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 2016-11-11
      相关资源
      最近更新 更多