读取本地图片并且将其转为byte[]

我读取的是streamingAssets文件夹下的

 string[] pathArr = Directory.GetFiles(Application.streamingAssetsPath);     
        print(pathArr.Length);
        for (int i = 0; i < pathArr.Length; i++)
        {
            if (pathArr[i].Contains("meta")) //避免将meta文件也加载进去
            {
                continue;
            }
            FileInfo file = new FileInfo(pathArr[i]);
            FileStream stream= file.OpenRead();
            byte[] buffer = new byte[file.Length];
            stream.Read(buffer, 0, file.Length);

ok,所见即所得,就是这样的!

猜你喜欢

转载自blog.csdn.net/chenzhe_n/article/details/81130522