如何获得Mono Xamarin Android应用程序路径文件夹?

vit*_*ent 5 c# mono android path xamarin

Mono(Xamarin)Android应用程序路径,怎么搞定?我发现了一种方法,我发现它看起来更好

string path = "";
System.Collections.IDictionary vars = System.Environment.GetEnvironmentVariables();
foreach (System.Collections.DictionaryEntry entry in vars)
{
     if (entry.Key.ToString().Contains("HOME"))
         path = entry.Value.ToString();
}
Run Code Online (Sandbox Code Playgroud)

use*_*er1 9

在您的Android应用程序中,您可以使用:

// Documents folder
string documentsPath = System.Environment.GetFolderPath(
   System.Environment.SpecialFolder.Personal);
Run Code Online (Sandbox Code Playgroud)

这将为您提供路径:

/data/data/YourAppName/files/
Run Code Online (Sandbox Code Playgroud)