Access tmp directory in iOS 8 with Xamarin.iOS
Asked Answered
N

3

5

Does anyone know how to get the path to the tmp directory in iOS 8 with Xamarin?

Nacreous answered 30/4, 2015 at 12:33 Comment(0)
M
7

Just try:

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

var tmp = Path.Combine(documents, "../", "tmp");
Mouthy answered 30/4, 2015 at 13:7 Comment(3)
Thanks. I'll try it. One question though: Will this the real tmp directory or a subdirectory of the Documents directory (which can be made available to the user through iTunes file sharing and will be backed up)?Nacreous
Interesting. He makes this path /Documents/../tmp/test.jpg. Through .. he is in the correct path.Nacreous
Was wondering about that strange path lately, too. For a detailed overview see developer.xamarin.com/guides/ios/application_fundamentals/…Mouthy
T
6

You can just use

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

This will return your app's tmp directory

Tribunal answered 22/5, 2017 at 17:44 Comment(0)
C
1
//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;
}
Cashew answered 16/6, 2016 at 22:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.