FileStream流媒体

class Program
    {
        static void Main(string[] args)
        {
            string source = @"mana.mp4";
            string target = @"fu.mp4";
            CopyFile(source, target);
            Console.WriteLine("复制成功");
            Console.ReadKey();
        }
        public static void CopyFile(string soucre, string target)
        {
            FileStream fsRead = new FileStream(soucre, FileMode.Open, FileAccess.Read);
            FileStream fsWrite = new FileStream(target,FileMode.OpenOrCreate,FileAccess.Write);
            byte[] buffer = new byte[1024*1024*5];
            while (true)
            {
                int r = fsRead.Read(buffer, 0, buffer.Length);
                if (r == 0)
                {
                    break;
                }
                fsWrite.Write(buffer, 0, r);
            }
        }
    }

 

posted @ 2015-12-11 15:05  满猪星  阅读(142)  评论(0编辑  收藏  举报