C# 文件操作 把文件读取到字节数组

string  zipfile = "c:\\a.zip";
                            //方法1
                            FileStream fs = new FileStream(zipfile, FileMode.Open);
                            //把文件读取到字节数组
                            byte[] zipdata = new byte[fs.Length];
                            fs.Read(zipdata, 0, zipdata.Length);
                            fs.Close();


                            //方法2
                            //把文件读取到字节数组
                            byte[] zipdata = File.ReadAllBytes(zipfile);

posted on 2016-07-03 20:09  武胜-阿伟  阅读(1298)  评论(0编辑  收藏  举报