Monodroid Environment variables

二次信任 提交于 2019-12-09 06:15:35

问题


In Android there are a collection of Environment paths available at Android.OS.Environment. However, when keeping cross platform capabilities in mind, I want to store pictures in a pictures folder and so thought to use System.Environment.GetFolderPath instead. However, my question is where these all point to in an Android environment. Can I get a useful pictures folder from the following?

string path = Environment.GetFolderPath (Environment.SpecialFolder.MyPictures);

回答1:


After stepping through some code, I've summarised the locations given by Xamarin Android for each of the different System.Environment variables below. I don't have an iOS project available, but if anyone could post the iOS equivalents I'd be grateful.

ApplicationData         "/data/data/ProjectName.ProjectName/files/.config"
CommonApplicationData   "/usr/share"
CommonProgramFiles      ""
Cookies                 ""
Desktop                 "/data/data/ProjectName.ProjectName/files/Desktop"
DesktopDirectory        "/data/data/ProjectName.ProjectName/files/Desktop"
Favorites               ""
History                 ""
InternetCache           ""
LocalApplicationData    "/data/data/ProjectName.ProjectName/files/.local/share"
MyComputer              ""
MyDocuments             "/data/data/ProjectName.ProjectName/files"
MyMusic                 "/data/data/ProjectName.ProjectName/files/Music"
MyPictures              "/data/data/ProjectName.ProjectName/files/Pictures"
MyVideos                "/data/data/ProjectName.ProjectName/files/Videos"
Personal                "/data/data/ProjectName.ProjectName/files"
ProgramFiles            ""
Programs                ""
Recent                  ""
SendTo                  ""
StartMenu               ""
Startup                 ""
System                  ""
Templates               "/data/data/ProjectName.ProjectName/files/Templates"



回答2:


Turns out this isn't available in iOS or Windows phone.

http://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_4_-_platform_divergence_abstraction_divergent_implementation (see section 3.1.4).



来源:https://stackoverflow.com/questions/16918307/monodroid-environment-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!