我已在.lcf
文件夹中加载了Assets
文件,并将构建操作设置为Content
。我得到一个例外,说该文件无法找到。
这是我从assets文件夹中读取.lcf
文件并将其存储在byte
数组中的方式:
byte[] buf = System.IO.File.ReadAllBytes("custom.lcf");
答案 0 :(得分:2)
使用AssetManager从资产中读取文件
byte[] buffer = new byte[16*1024];
byte[] data;
AssetManager assets = this.Assets;
using (Stream input = assets.Open ("custom.lcf")) {
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
data = ms.ToArray();
}
}