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);
相關文章
相關標籤/搜索