【问题标题】:DirectoryNotFoundException occurred in xamarin forms ios using plugin.media.crossmedia使用 plugin.media.crossmedia 在 xamarin 表单 ios 中发生 DirectoryNotFoundException
【发布时间】:2021-02-04 07:14:08
【问题描述】:
using (var file = await CrossMedia.Current.TakePhotoAsync(options))
{
   .....
}

我正在使用跨媒体以 xamarin 形式 ios(以上代码)拍照。我在应用中心收到此错误,

System.IO.DirectoryNotFoundException:找不到路径的一部分“/var/mobile/Containers/Data/Application/D9CD5B7E-D0AD-41A1-97DA-9B6FC4471955/Documents/myapp/2266603_21-1-2021-12 -0-21-4152..jpg"

如何解决这个错误?

Error Message:
{
    "length": 0,
  "offset": 0,
  "id": "4be55b3c-33f1-4bbf-99a3-b4af8203a0ba",
  "exception": {
        "type": "System.IO.DirectoryNotFoundException",
    "message": "Could not find a part of the path \"/var/mobile/Containers/Data/Application/D9CD5B7E-D0AD-41A1-97DA-9B6FC4471955/Documents/myapp/2266603_21-1-2021-12-1-19-8643..jpg\".",
    "stackTrace": "  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x102720700 + 0x00214> in <0c3d4da7367647c9a650750b1a4d0c53#649cd0243319b7ca5a9179e97f48de1f>:0 \n  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) <0x102720650 + 0x0008f> in <0c3d4da7367647c9a650750b1a4d0c53#649cd0243319b7ca5a9179e97f48de1f>:0 \n  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access) <0x102720420 + 0x0006f> in <0c3d4da7367647c9a650750b1a4d0c53#649cd0243319b7ca5a9179e97f48de1f>:0 ",
    "wrapperSdkName": "appcenter.xamarin"
  },
  "properties": {
        "message:": "Could not find a part of the path \"/var/mobile/Containers/Data/Application/D9CD5B7E-D0AD-41A1-97DA-9B6FC4471955/Documents/myapp/2266603_21-1-2021-12-1-19-8643..jpg\".",
    
  },
  "appId": "5993bbda-3072-45e5-9418-a260aa66a94f",
  "installId": "761843BC-C04F-4E62-A3EB-C636C58CEFF7",
  "isTestMessage": false,
  "timestamp": "2021-02-03T03:44:15.833Z",
  "sid": "5e3c4238-d2cc-42da-8ab4-319d4c97b21a",
  "device": {
        "sdkName": "appcenter.ios",
    "sdkVersion": "4.0.0",
    "wrapperSdkVersion": "4.0.0",
    "wrapperSdkName": "appcenter.xamarin",
    "model": "iPad7,5",
    "oemName": "Apple",
    "osName": "iOS",
    "osVersion": "14.3",
    "osBuild": "18C66",
    "locale": "en_AE",
    "timeZoneOffset": 240,
    "screenSize": "2048x1536",
    "appVersion": "3.1.1",
    "appBuild": "3.9",
    "appNamespace": "com.myapp",
    "wrapperRuntimeVersion": "12.6.0"
  }
}

【问题讨论】:

  • SoftDev :当您尝试存储文件时会发生此异常,对吗?您在将数据存储到其中之前创建了目录吗?
  • CrossMedia 为 android 和 ios 创建目录。我能够在android中看到路径目录。在ios中看不到目录。有没有可能看到ios设备文件目录?
  • 我想我看到了你的问题。您能否分享更多您存储文件路径和检索它的代码?

标签: xamarin xamarin.forms xamarin.ios media plugin.media.crossmedia


【解决方案1】:

假设您已经发布了所有相关代码并且您可以使用它来重现错误,那么插件中就会发生异常。因此,您需要将问题提交给插件作者,以便他们解决。

【讨论】:

    【解决方案2】:

    出于某种原因,您正在寻找此文件 myapp/2266603_21-1-2021-12-1-19-8643..jpg。 注意有两个“..”吗?

    您应该修复您的代码,以便它尝试引用 myapp/2266603_21-1-2021-12-1-19-8643.jpg

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      • 1970-01-01
      相关资源
      最近更新 更多