簡(jiǎn)介
綜合分析下不同平臺(tái)、不同API的讀寫權(quán)限雌桑,以及對(duì)應(yīng)的System.IO
和www
兩種操作方式區(qū)別
讀寫方式
-
System.IO
:部分平臺(tái)部分API不可用
-
www
:都可用腕让,但要注意不同平臺(tái)不同路徑是否需要添加訪問(wèn)名稱;正撑材猓可能是需要添加的,但Android平臺(tái)的streamingAssetsPath的路徑本身就是擁有前綴的击你,不需要額外加
public void LoadByWWW(string path)
{
StartCoroutine(doLoadByWWW(path));
}
IEnumerator doLoadByWWW(string url)
{
WWW w = new WWW(url);
yield return w;
if (w.isDone){}
else{}
}
API
平臺(tái) |
可讀 |
可寫 |
路徑 |
讀寫操作 |
備注 |
pc |
true |
true |
<項(xiàng)目地址>/Assets |
IO可以玉组,www加前綴"file://" |
該路徑可以訪問(wèn)項(xiàng)目文件夾下的所有資源 |
android |
false |
false |
/data/app/xxx.xxx.xxx.apk |
IO和www都沒(méi)用 |
|
ios |
true |
false |
Application/xxx-xx/xxx.app/Data |
IO沒(méi)問(wèn)題,www加前綴"file://" |
|
- streamingAssetsPath:
這個(gè)文件夾中的資源在打包時(shí)會(huì)原封不動(dòng)的打包進(jìn)去丁侄,不會(huì)壓縮惯雳,一般放置一些資源數(shù)據(jù)
平臺(tái) |
可讀 |
可寫 |
路徑 |
讀寫操作 |
備注 |
pc |
true |
true |
<項(xiàng)目地址>/Assets/StreamingAssets |
IO可以,www加前綴"file://" |
|
android |
true |
false |
jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
|
不能IO鸿摇,www不用加前綴直接用石景,路徑自帶前綴 |
路徑相當(dāng)于jar:file:// + dataPath + !/assets |
ios |
true |
true |
Application/xxxxx-xxxx/xxx.app/Data/Raw |
IO可以,www加前綴"file://" |
|
- persistentDataPath:
這個(gè)路徑只能在程序運(yùn)行時(shí)才能讀寫操作拙吉,不能提前將數(shù)據(jù)放入這個(gè)路徑
平臺(tái) |
可讀 |
可寫 |
路徑 |
讀寫操作 |
備注 |
pc |
true |
true |
C:/Users/xxx/AppData/LocalLow/DefaultCompany |
IO可以潮孽,www加前綴"file://" |
|
android |
true |
true |
/data/data/xxx.xxx.xxx/files |
IO可以,www加前綴"jar:file://" |
位置根據(jù)Write Access設(shè)置筷黔,可以是程序沙盒或者sdcard往史;如果保存在沙盒,就必須root才能用電腦取出文件佛舱,因此建議寫入sdcard里 |
ios |
true |
true |
Application/x-xxxx-xxx/Documents |
IO可以椎例,www加前綴"file://" |
位置在應(yīng)用程序的沙盒挨决,可以被iCloud自動(dòng)備份 |
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者