Click here to Skip to main content
11,923,676 members (66,614 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked

Quick and dirty directory copy

, 17 Jan 2006
Rate this:
Please Sign up or sign in to vote.
Quick directory copy to another directory.


I saw a program to speed up the file copying process but I wanted to add some features to it, like, skip overwriting existing files, or no copying of existing files. Also, I wanted to control and monitor the copy process by a better method.


I think you have to know how to manage a thread, and must be familiar with memory buffers. That's all Smile | :)

File.Read(bytesArray,Offset ,bufferSize);

Using the code

This code abstractly copies files from one path to another path, by read portions (equal to the buffer size) then writing it on the destination file, then looping the same for all files on the source directory. It displays progress information for a file, for the current directory, and for the entire copy process.

public string File_Copy(string strSource, 
          string strDestination,FileMode mode, 
          int bufferSize,int Action)
    byte[] Readbytes;
    Readbytes = new byte[bufferSize];
    ///1 read file Binary 
    FileStream Sfs = File.OpenRead(strSource);
    Dfs = File.Open(strDestination,mode);
    FileInfo Sinfo = new FileInfo(Sfs.Name);
    FileInfo Dinfo=new FileInfo(Dfs.Name);
    //Set Progress File Name On Form1
    Form1.progCurrentFile.Text = strSource;
    while (Sfs.Length - Sfs.Position>=bufferSize)
        //Read Buffer
        //Write Buffer

        ///try to change Buffer Size at Copping file 
        bufferSize = Settings.bufferSize;
        Readbytes = null;
        Readbytes = new  byte[Settings.bufferSize];
        //end try 

        // Write the Reminder to buffer If any
        if (Sfs.Position < Sfs.Length)
              int.Parse(Sfs.Length.ToString()) - 
              int.Parse(Sfs.Length.ToString()) - 
            //Check for program Changes
            //Do Events 
    //end write 

Points of Interest

Current features:

  1. Copy files/directories from source directory to distention directory.
  2. Control memory buffer to speed up the copy process.
  3. Scan source directory to see all the files and directories inside, and get abstract info about the source directory.
  4. Pause / resume / cancel the copy process.
  5. Progress bars for a file, directory, and the copy process.
  6. In case of a damaged file found, it doesn't skip the copy process as Windows does. But it tells the user about it and the user can choose from one of the following options: write whatever can be written from the source file to the destination file /skip this file /skip all damaged files /write whatever can be written for all damaged files found.

Using the executable

  1. Copy
    • Click on the Source button to select the source directory.
    • Click on the Destination button to select where you want to copy it to.

    Now you can click Copy to start copying files. You may click on Progress to see how fast the files are copied and the actual percentage of completion. You may change the buffer size to speed up / slow down the copy process. You can also pause /resume /cancel the copy process at any time.

  2. Get information of a directory

    You can use this application to get information about a particular directory, like, how many files are inside a directory, the names of files, size information, etc.

    • Select a source directory.
    • Click on the Info button.
    • You may also select the Info tab to see an information display about the source directory.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Egypt Egypt
Tareq Gamal el-din Mohammed ,
Finalized the Study of Computer education at Modern Academy at Egypt ,
Then had many Microsoft Official Certificates like:
MCAD.NET (Microsoft Certified Application Developer)
MCSD.NET (Microsoft Certified Solution Developer)
Also others for SharePoint from some private sector education centers.

Robotics fields was a Hobby since 2002 ,
started to develop some applications for "RoboSapien","RS Media" ,and RoboMe. from Wowwee company,

after that started working with robots as professional way. at 2014
By using "NAO" Robot from Aldebaran.

By developing some applications and libraries like :

OpenCV with NAO Robot:

- NAORobot Vision using OPENCV -TotaRobot P1

- NAO Robot Vision using OPENCV - P2

NAO Alarm Clock :

Other Projects Developed by Tareq Gamal El-din Mohammed :

Developed and posted some applications in Code Project web site like :

- Control your Distributed Application using Windows and Web Service

- Quick and dirty directory copy

- Program Execute Timer(From the Web)

details in the other account :


You may also be interested in...

Comments and Discussions

Generalcopy to 0 Pin
DavidDou8-Feb-07 7:13
memberDavidDou8-Feb-07 7:13 
GeneralRe: copy to 0 Pin
tareqGamal9-Mar-07 11:10
membertareqGamal9-Mar-07 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151125.3 | Last Updated 17 Jan 2006
Article Copyright 2006 by Tareq_Gamal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid