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);

你可能感兴趣的:(C# 文件操作 把文件读取到字节数组)