C#大文件拷贝方法—文件拷贝方法

     public static void FileCopy(string source,string target)
        {
            using (FileStream fileRead = new FileStream(source, FileMode.Open, FileAccess.Read))
            {
                byte[] bb = new byte[1024 * 1024 * 5];
               int r= fileRead.Read(bb, 0, bb.Length);
                using(FileStream fileWrite=new FileStream(target, FileMode.Create, FileAccess.Write))
                {
                    while (r > 0)
                    {
                        fileWrite.Write(bb, 0, r);
                        r = fileRead.Read(bb, 0, bb.Length);
                    }
                }
                
            }
        }

评论