با استفاده از بافر می توان روی مقدار کپی شدن یه فایل مدیریت کرد و مانور داد
موارد مورد نیاز برای این مثال:
1. یک Progress Bar
2. یک Button
این کد متد اصلی ما می باشد
        public void CopyFile(string FileSource, string FileDestination)
        {
            int NumRead;
            long FileLength;
            System.IO.FileStream From = new System.IO.FileStream(FileSource, System.IO.FileMode.Open);
            System.IO.FileStream To = new System.IO.FileStream(FileDestination, System.IO.FileMode.CreateNew);
            byte[] buffer = new byte[1024];
            FileLength = From.Length;
            progressBar1.Minimum = 0;
            progressBar1.Maximum = (int)FileLength;
                while (FileLength>0)
                {
                    System.IO.BinaryReader Reader = new System.IO.BinaryReader(From);
                    NumRead = Reader.Read(buffer, 0, 1024);
                    FileLength = FileLength - NumRead;
                    System.IO.BinaryWriter Writer = new System.IO.BinaryWriter(To);
                    Writer.Write(buffer, 0, NumRead);
                    progressBar1.Value = progressBar1.Value + NumRead;
                    Writer.Flush();
                }
            From.Close();
            To.Close();
                if (progressBar1.Value>99)
                {
                    progressBar1.Value = 0;
                    MessageBox.Show("Copy Finished successfuly");
                }
        }
از این کد برای فراخوانی متد اصلی در رویداد Button استفاده می شود
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            folderBrowserDialog1.ShowDialog();
            System.IO.FileInfo d=new System.IO.FileInfo(openFileDialog1.FileName.ToStri  ng());
            CopyFile(openFileDialog1.FileName.ToString(), folderBrowserDialog1.SelectedPath.ToString()+"\\"+  d.Name.ToString());
        }