C#读写二进制文件

 

FileStream fs1 = new FileStream(@"E:\ring\doc\目标.xls", FileMode.Open, FileAccess.Read, FileShare.Read);
FileStream fs2 = new FileStream(@"E:\ring\doc\目标22.xls", FileMode.Create, FileAccess.Write, FileShare.None);
        byte []farr = new byte[1024];
        const int rbuffer=1024;
        //fs1.ReadByte(); //读取单个字节,返回-1表示读完
        while (fs1.Read(farr, 0, rbuffer)!=0) //返回0表示读完
        {
            fs2.Write(farr, 0, rbuffer);
        }
        fs1.Close();
        fs2.Close();

posted on 2009-02-13 20:06  ringwang  阅读(3473)  评论(0编辑  收藏  举报