简体   繁体   中英

How get Mono Xamarin Android app path folder?

Mono (Xamarin) Android application path, how do get? I found one way, it look like better I found

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();
}

In your Android application you could use:

// Documents folder
string documentsPath = System.Environment.GetFolderPath(
   System.Environment.SpecialFolder.Personal);

This will get you the path:

/data/data/YourAppName/files/

I think this is what you need. Give the local files root.

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData

and when you need get a file's full name you can do something like this:

string _fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "filename.txt");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM