【问题标题】:Access tmp directory in iOS 8 with Xamarin.iOS使用 Xamarin.iOS 访问 iOS 8 中的 tmp 目录
【发布时间】:2015-04-30 12:33:09
【问题描述】:

有谁知道如何使用 Xamarin 在 iOS 8 中获取到 tmp directory 的路径?

【问题讨论】:

  • 你能解释一下否决票吗?例如。给出答案?有类似var caches = Path.Combine (NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User) [0].Path, "Caches"); 的东西吗?
  • 不知道为什么会有反对票,只是对你的问题投了赞成票 ;-)。

标签: c# ios8 xamarin xamarin.ios tmp


【解决方案1】:

试试吧:

var documents = NSFileManager.DefaultManager
    .GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].Path;

var tmp = Path.Combine(documents, "../", "tmp");

【讨论】:

  • 谢谢。我会试试看。但是有一个问题:这是真正的tmp 目录还是Documents 目录的子目录(可以通过iTunes 文件共享提供给用户并进行备份)?
  • 有趣。他走这条路/Documents/../tmp/test.jpg。通过..,他走在了正确的道路上。
  • 最近也在想那条奇怪的路。有关详细概述,请参阅developer.xamarin.com/guides/ios/application_fundamentals/…
【解决方案2】:

你可以使用

var tmp = System.IO.Path.GetTempPath ();

这将返回您应用的 tmp 目录

【讨论】:

    【解决方案3】:
    //https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system
    public string TempPath()
    {           
        var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        var ret = Path.Combine(documents, "..", "tmp");
        return ret;
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-29
      • 1970-01-01
      • 2011-01-04
      • 2018-07-12
      • 1970-01-01
      • 1970-01-01
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多