編輯 1
在 VS for Mac 中,它實際上按預期作業。對我來說,所描述的行為僅發生在 Rider 2022.2.2 中。
原始問題
在我的 Xamarin Android 專案中,我有一個檔案夾“Assets”,其中包括一個資產檔案“certificate.crt”。該檔案的構建操作設定為 AndroidAsset。為了能夠使用資產管理器訪問資產,我必須指定完整的檔案路徑。
var assetManager = Android.App.Application.Context.Assets;
using (var certStream = assetManager.Open("Users/myuser/Documents/Projects/MyProject/MyProject.Android/Assets/certificate.crt"))
{
// use the certStream
}
我通過將 .apk 重命名為 .zip 并解壓縮檔案找到了檔案路徑。因此 .apk 包含一個“資產”檔案夾,其中包含上面指定的所有檔案夾。但我顯然想要的只是將檔案名傳遞給資產管理器。
assetManager.Open("certificate.crt")
我該如何做到這一點?
uj5u.com熱心網友回復:
所以這似乎是 Rider for Mac 中的一個錯誤。VS for Mac 按預期作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/507018.html
標籤:C# xamarin xamarin.forms xamarin.android 安卓资产