unity5在为ios打包资源的时候,提示:
error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'
很奇怪的问题,后来自己写了读写函数,解决!
///
/// 擦写文件(用于替换系统File的同名静态方法)
///
///
///
///
///
public static void WriteAllBytes(string file,byte[] data,int offset = 0,int length = -1)
{
if (length == -1) length = data.Length - offset;
FileStream fs = new FileStream(file, FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
w.Write(data,offset,length);
w.Flush();
w.Close();
fs.Close();
}
///
/// 读取文件(用于替换系统File的同名静态方法)
///
///
///
///
public static byte[] ReadAllBytes(string file)
{
FileStream fs = new FileStream(file, FileMode.Open);
BinaryReader r = new BinaryReader(fs);
byte[] data = r.ReadBytes((int)fs.Length);
r.Close();
fs.Close();
return data;
}